UNPKG

@samepage/internal

Version:

Utilities used across modules - not meant for use by users directly

20 lines 791 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.onAppEvent = exports.listeners = void 0; exports.listeners = {}; const onAppEvent = (t, callback) => { // @ts-ignore Why doesn't this work? if (exports.listeners[t]) exports.listeners[t].push(callback); // @ts-ignore Why doesn't this work? else exports.listeners[t] = [callback]; return () => { var _a, _b; const index = (_a = exports.listeners[t]) === null || _a === void 0 ? void 0 : _a.indexOf(callback); if (typeof index === "number" && index >= 0) (_b = exports.listeners[t]) === null || _b === void 0 ? void 0 : _b.splice(index, 1); }; }; exports.onAppEvent = onAppEvent; //# sourceMappingURL=registerAppEventListener.js.map