export class EventHandler {
  constructor() {
    this.subscribers = {};
  }

  addEventListener(type, handler) {
    if (!this.subscribers[type]) this.subscribers[type] = [];
    this.subscribers[type].push(handler);
  }

  emit(type, ...data) {
    if (this.subscribers[type])
      this.subscribers[type].forEach((handler) => handler(...data));
  }
}
