class EventBus { emits: Map = new Map(); on(name: string, callback: Function) { this.emits.set(name, callback); }; off(name: string) { this.emits.delete(name); }; exists(name: string) { return this.emits.has(name); } emit(name: string, ...arg: any[]) { if (this.emits.has(name)) { let cb = this.emits.get(name) return cb!(...arg) } }; } export default EventBus