Download react-query/packages/vue-query/src/useIsFetching.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/packages/vue-query/src/useIsFetching.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/packages/vue-query/src/useIsFetching.ts
-
curl -L -o useIsFetching.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/packages/vue-query/src/useIsFetching.ts
1.1 kB
| import { getCurrentScope, onScopeDispose, ref, watchEffect } from 'vue-demi' | |
| import { useQueryClient } from './useQueryClient' | |
| import type { Ref } from 'vue-demi' | |
| import type { QueryFilters as QF } from '@tanstack/query-core' | |
| import type { MaybeRefDeep } from './types' | |
| import type { QueryClient } from './queryClient' | |
| export type QueryFilters = MaybeRefDeep<QF> | |
| export function useIsFetching( | |
| fetchingFilters: MaybeRefDeep<QF> = {}, | |
| queryClient?: QueryClient, | |
| ): Ref<number> { | |
| if (process.env.NODE_ENV === 'development') { | |
| if (!getCurrentScope()) { | |
| console.warn( | |
| 'vue-query composable like "useQuery()" should only be used inside a "setup()" function or a running effect scope. They might otherwise lead to memory leaks.', | |
| ) | |
| } | |
| } | |
| const client = queryClient || useQueryClient() | |
| const isFetching = ref() | |
| const listener = () => { | |
| isFetching.value = client.isFetching(fetchingFilters) | |
| } | |
| const unsubscribe = client.getQueryCache().subscribe(listener) | |
| watchEffect(listener) | |
| onScopeDispose(() => { | |
| unsubscribe() | |
| }) | |
| return isFetching | |
| } | |