INNER CODE UNIT · JavaScript
EventBus
rohitg00/k8sgames · js/engine/GameEngine.js:5
class EventBus {
constructor() {
this._handlers = new Map();
this._onceHandlers = new Map();
this._history = [];
this._maxHistory = 200;
this._wildcardHandlers = [];
}
on(event, handler) {
if (!this._handlers.has(event)) {
this._handlers.set(event, []);
}
this._handlers.get(event).push(handler);
return () => this.off(event, handler);
}
once(event, handler) {