(event: string, callback: (payload: any) => void)
| 337 | } |
| 338 | |
| 339 | on(event: string, callback: (payload: any) => void): number { |
| 340 | if (!this.handlers.has(event)) { |
| 341 | this.handlers.set(event, []); |
| 342 | } |
| 343 | const ref = this.nextRef++; |
| 344 | this.handlers.get(event)!.push({ ref, callback }); |
| 345 | return ref; |
| 346 | } |
| 347 | |
| 348 | off(event: string, ref?: number): void { |
| 349 | if (!this.handlers.has(event)) return; |