UNPKG

use-app-events

Version:

Create custom events and reactive variables in vanilla JavaScript and React.

29 lines (28 loc) 1.17 kB
import e from "../../lib/heap.js"; import t from "../../lib/options.js"; import { broadcastMessage as n } from "../../broadcast/broadcastMessage.js"; import { createMessage as r } from "../../broadcast/utils/createMessage.js"; import "../../utils/debugMessage.js"; //#region src/base/notifyEventListeners/notifyEventListeners.ts var i = (i) => { let { debug: a, scopeKey: o } = i || {}, s = typeof o == "string" ? `(instance ${o})` : ""; return (i, o, c = t.broadcast) => { a ?? t.debug; let l; l = Array.isArray(i) ? i : [i], l.forEach((t) => { `${s}${t}`; let i = /* @__PURE__ */ new Set(); e.eventListeners.forEach((e) => { if (e.eventType === t) { let n = i.has(e.eventGroupId), r = e.shouldBeCalledOnce && e.hasBeenCalled; if (n || r) return; e.hasBeenCalled = !0, e.eventGroupId && (e.shouldBeCalledOnce && i.add(e.eventGroupId), e.callback(t, o)), e.eventGroupId || e.callback(o); } }), e.eventListeners.forEach((e) => { e.shouldBeCalledOnce && e.eventGroupId && i.has(e.eventGroupId) && (e.hasBeenCalled = !0); }), c && n(r(t, o)); }); }; }; //#endregion export { i as base_createNotifyEventListeners };