class EventEmitter { constructor(){ this.listeners = [] } on(eventName,func){ const callbacks = this.listen[eventName] || [] callbacks.push(func); this.listeners[eventName]=callbacks } off(eventName,func){ } emit(eventName,...args){ const callbacks = this.listens[eventName] if(callbacks.length>0){ callbacks.forEach((callback)=>{ callback(...args) }) } } }