Skip to content

Commit 280682e

Browse files
authored
fix(query-broadcast-client): allow passing all broadcast-channel options (#5925)
* fix(query-broadcast-client): allow passing in type for the channel allowed values are: 'native', 'idb', 'localstorage', 'node' * fix(query-broadcast-client): allow passing all broadcast-channel options * docs: options
1 parent 34f1e8c commit 280682e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

docs/react/plugins/broadcastQueryClient.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ interface broadcastQueryClient {
4747
/** This is the unique channel name that will be used
4848
* to communicate between tabs and windows */
4949
broadcastChannel?: string
50+
/** Options for the BroadcastChannel API */
51+
options?: BroadcastChannelOptions
5052
}
5153
```
5254

packages/query-broadcast-client-experimental/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { BroadcastChannel } from 'broadcast-channel'
2+
import type { BroadcastChannelOptions } from 'broadcast-channel'
23
import type { QueryClient } from '@tanstack/query-core'
34

45
interface BroadcastQueryClientOptions {
56
queryClient: QueryClient
67
broadcastChannel?: string
8+
options?: BroadcastChannelOptions
79
}
810

911
export function broadcastQueryClient({
1012
queryClient,
1113
broadcastChannel = 'tanstack-query',
14+
options,
1215
}: BroadcastQueryClientOptions) {
1316
let transaction = false
1417
const tx = (cb: () => void) => {
@@ -19,6 +22,7 @@ export function broadcastQueryClient({
1922

2023
const channel = new BroadcastChannel(broadcastChannel, {
2124
webWorkerSupport: false,
25+
...options,
2226
})
2327

2428
const queryCache = queryClient.getQueryCache()

0 commit comments

Comments
 (0)