| 110 | } |
| 111 | |
| 112 | off(event: string, callback?: (data: any) => any) { |
| 113 | if (!callback) { |
| 114 | this.eventHandlers.delete(event as string) |
| 115 | } else { |
| 116 | const handlers = this.eventHandlers.get(event as string) |
| 117 | if (handlers) { |
| 118 | const index = handlers.indexOf(callback) |
| 119 | if (index !== -1) { |
| 120 | handlers.splice(index, 1) |
| 121 | if (handlers.length === 0) { |
| 122 | this.eventHandlers.delete(event as string) |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | on(event: string, callback?: (data: any) => any): void { |
| 130 | if (!callback) { |