@aotearoan/neon
Version:
Neon is a lightweight design library of Vue 3 components with minimal dependencies.
45 lines (44 loc) • 1.48 kB
JavaScript
var f = Object.defineProperty;
var h = (r, s, i) => s in r ? f(r, s, { enumerable: !0, configurable: !0, writable: !0, value: i }) : r[s] = i;
var l = (r, s, i) => (h(r, typeof s != "symbol" ? s + "" : s, i), i);
const t = class t {
/**
* Start listening to event bus events.
*
* @param event The event topic to listen for.
* @param callback Callback to be triggered when an event is received.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static on(s, i) {
t.listeners[s] || (t.listeners[s] = []), t.listeners[s].push(i);
}
/**
* Stop listening to event bus events.
*
* @param event The event topic to listen for.
* @param callback Callback to stop triggering.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static off(s, i) {
t.listeners[s] = t.listeners[s].filter((e) => e !== i);
}
/**
* Emit an event bus event on a specific topic.
*
* @param event The topic on which to send the event.
* @param args The event arguments to send.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static emit(s, ...i) {
var e;
(e = t.listeners[s]) == null || e.forEach((c) => c(...i));
}
};
/** Message prefix used for Neon internal messages. */
l(t, "messagePrefix", "neon-"), // eslint-disable-next-line @typescript-eslint/no-explicit-any
l(t, "listeners", {});
let a = t;
export {
a as NeonEventBus
};
//# sourceMappingURL=NeonEventBus.es.js.map