(
event: TanStackDevtoolsEvent<string>,
fromBroadcastChannel = false,
)
| 111 | } |
| 112 | |
| 113 | private emitToClients( |
| 114 | event: TanStackDevtoolsEvent<string>, |
| 115 | fromBroadcastChannel = false, |
| 116 | ) { |
| 117 | this.debugLog('Emitting event from client bus', event) |
| 118 | const specificEvent = new CustomEvent(event.type, { detail: event }) |
| 119 | this.debugLog('Emitting event to specific client listeners', event) |
| 120 | this.#eventTarget.dispatchEvent(specificEvent) |
| 121 | const globalEvent = new CustomEvent('tanstack-devtools-global', { |
| 122 | detail: event, |
| 123 | }) |
| 124 | // We only emit the events if they didn't come from the broadcast channel |
| 125 | // otherwise it would infinitely send events between |
| 126 | if (!fromBroadcastChannel) { |
| 127 | this.#broadcastChannel?.postMessage(stringifyWithBigInt(event)) |
| 128 | } |
| 129 | this.debugLog('Emitting event to global client listeners', event) |
| 130 | this.#eventTarget.dispatchEvent(globalEvent) |
| 131 | } |
| 132 | |
| 133 | private flushPendingServerEvents() { |
| 134 | if (!this.#socket || this.#socket.readyState !== WebSocket.OPEN) { |
no test coverage detected