Skip to content

Commit

Permalink
chore(Queries): add typing example
Browse files Browse the repository at this point in the history
  • Loading branch information
amen-souissi committed Jan 22, 2022
1 parent 76d0591 commit e0b5e05
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/queryCore/broadcastQueryClient-experimental/index.ts
@@ -1,15 +1,16 @@
import { BroadcastChannel } from 'broadcast-channel'
import { QueryClient } from '../core'

interface BroadcastQueryClientOptions {
queryClient: QueryClient
broadcastChannel?: string
}

export function broadcastQueryClient({
export async function broadcastQueryClient({
queryClient,
broadcastChannel = 'svelte-query',
}: BroadcastQueryClientOptions) {
const { BroadcastChannel } = await import('broadcast-channel')

let transaction = false
const tx = (cb: () => void) => {
transaction = true
Expand Down
10 changes: 9 additions & 1 deletion storybook/stories/queries/Queries.svelte
Expand Up @@ -20,7 +20,15 @@
{ queryKey: 'myQuery3', queryFn: queryFn3 },
] as const
const queriesStore = useQueries(queries)
const queriesStore = useQueries<
[{ queryFnData: string }, { queryFnData: string }, { queryFnData: boolean }]
>(queries)
// TS Error
// const queriesStore = useQueries<
// [{ queryFnData: string }, { queryFnData: string }, { queryFnData: string }]
// >(queries)
// can pass only TData (data prop) although TQueryFnData will be left unknown
// Please see QueriesOptions for more details
</script>

<main>
Expand Down

0 comments on commit e0b5e05

Please sign in to comment.