libre-routing
Version:
This library was generated with [Nx](https://nx.dev).
18 lines • 545 B
JavaScript
export class Dispatcher {
constructor() {
this.callbacks = {};
}
fire(event, data) {
this.getEventCallbacks(event).forEach((callback) => callback(data));
}
on(event, callback) {
this.callbacks[event] = [...this.getEventCallbacks(event), callback];
}
off(event, callback) {
this.callbacks[event] = this.getEventCallbacks(event).filter((c) => c !== callback);
}
getEventCallbacks(event) {
return this.callbacks[event] || [];
}
}
//# sourceMappingURL=dispatcher.js.map