import mitt from 'mitt';

class EventEmitter {
  constructor() {
    this.emitter = mitt();
  }

  on(eventName, handler) {
    this.emitter.on(eventName, handler);
  }

  off(eventName, handler) {
    this.emitter.off(eventName, handler);
  }

  emit(eventName, event) {
    this.emitter.emit(eventName, event);
  }

  removeAllListeners() {
    this.emitter.all.clear();
  }
}

export default EventEmitter;
