UNPKG

@sitesoft/ssp-support

Version:

Various tools, data-structures and utils

48 lines (38 loc) 845 B
export class BusEvent { constructor(Vue) { this.bus = new Vue(); Vue.prototype.bus = this; } /** * Register a listener on Alice's built-in event bus */ $on(event, callback) { this.bus.$on(event, callback); // $on(event: string | string[], callback: Function): this } /** * Register a one-time listener on the event bus */ $once(event, callback) { this.bus.$once(event, callback); } /** * Unregister an listener on the event bus */ $off(event, callback) { this.bus.$off(event, callback); } /** * Emit an event on the event bus */ $emit(event, ...args) { this.bus.$emit(event, ...args); } } let instance; export default function receiveBus(Vue) { if (!instance) { instance = new BusEvent(Vue); } return instance; } //# sourceMappingURL=BusEvent.js.map