Open History to see the last commit
1import { getIsRestoringContext } from './context.js'
2import type { Box } from './containers.svelte.js'
3β
4/**
5 * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` function alongside it to
6 * check if a restore is currently in progress. `createQuery` and friends also check this internally to avoid
7 * race conditions between the restore and mounting queries.
8 * @returns A reactive box β read `.current` for `true` while a persisted client is being restored, `false`
9 * otherwise.
10 * @example
11 * ```svelte
12 * <script lang="ts">
13 * import { useIsRestoring } from '@tanstack/svelte-query'
14 *
15 * const isRestoring = useIsRestoring()
16 * </script>
17 *
18 * {#if isRestoring.current}
19 * <div>Restoring cached data...</div>
20 * {/if}
21 * ```
22 */
23export function useIsRestoring(): Box<boolean> {
24 return getIsRestoringContext()
25}