Skip to content

Commit 82a7617

Browse files
Chore/fix issue with broadcast channel (#106)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent a638170 commit 82a7617

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.changeset/little-buttons-sip.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/devtools-event-bus': patch
3+
---
4+
5+
fix issue with broadcast channel not emitting functions properly and failing

packages/event-bus/src/client/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class ClientEventBus {
5555
this.#connectToServerBus = connectToServerBus
5656
this.#eventTarget = this.getGlobalTarget()
5757
this.#broadcastChannel.onmessage = (e) => {
58-
this.emitToClients(e.data, true)
58+
this.emitToClients(JSON.parse(e.data), true)
5959
}
6060
this.debugLog('Initializing client event bus')
6161
}
@@ -74,7 +74,7 @@ export class ClientEventBus {
7474
// We only emit the events if they didn't come from the broadcast channel
7575
// otherwise it would infinitely send events between
7676
if (!fromBroadcastChannel) {
77-
this.#broadcastChannel?.postMessage(event)
77+
this.#broadcastChannel?.postMessage(JSON.stringify(event))
7878
}
7979
this.debugLog('Emitting event to global client listeners', event)
8080
this.#eventTarget.dispatchEvent(globalEvent)

0 commit comments

Comments
 (0)