diff --git a/src/functions/EventEmitter.js b/src/functions/EventEmitter.js deleted file mode 100644 index feeab7dc..00000000 --- a/src/functions/EventEmitter.js +++ /dev/null @@ -1,45 +0,0 @@ - -// TODO: Remove - use ts event emitter -export class EventEmitter { - constructor() { - this._events = {}; - }; - - addListener(eventKey, listener) { - // initialize - if (!this._events[eventKey]) { - this._events[eventKey] = []; - }; - - this._events[eventKey].push(listener); - }; - - removeListener(eventKey, listenerToRemove) { - // event does not exist - if (!this._events[eventKey]) return; - - this._events[eventKey] = this._events[eventKey].filter(listener => ( - listener !== listenerToRemove - )); - }; - - once(eventKey, listener){ - this.addListener(eventKey, (data) => { - listener?.(); - this.removeListener(eventKey, listener); - }); - }; - - removeAllListeners(){ - this._events = {}; - }; - - emit(eventKey, data) { - // event does not exist - if (!this._events[eventKey]) return; - - this._events[eventKey].forEach(callback => { - callback?.(data); - }); - }; -}; \ No newline at end of file