()
| 401 | * have missed events while the socket was disconnected or out of sync. |
| 402 | * |
| 403 | * Returns an unsubscribe function. Calling it removes the handler. |
| 404 | */ |
| 405 | onResync(handler: () => void): () => void { |
| 406 | this.resyncHandlers.add(handler); |
| 407 | return () => { |
| 408 | this.resyncHandlers.delete(handler); |
| 409 | }; |
| 410 | } |
| 411 | |
| 412 | on(event: string, handler: (context: string, payload: unknown) => void): () => void { |
| 413 | let handlers = this.eventHandlers.get(event); |
| 414 | if (!handlers) { |