()
| 6 | |
| 7 | /** Retrieves a Client from Svelte's context */ |
| 8 | export const getQueryClientContext = (): QueryClient => { |
| 9 | const client = getContext<QueryClient | undefined>(_contextKey) |
| 10 | if (!client) { |
| 11 | throw new Error( |
| 12 | 'No QueryClient was found in Svelte context. Did you forget to wrap your component with QueryClientProvider?', |
| 13 | ) |
| 14 | } |
| 15 | |
| 16 | return client |
| 17 | } |
| 18 | |
| 19 | /** Sets a QueryClient on Svelte's context */ |
| 20 | export const setQueryClientContext = (client: QueryClient): void => { |