UNPKG

@tanstack/vue-query

Version:

Hooks for managing, caching and syncing asynchronous and remote data in Vue

27 lines 902 B
// src/useIsFetching.ts import { getCurrentScope, onScopeDispose, ref, watchEffect } from "vue-demi"; import { useQueryClient } from "./useQueryClient.js"; function useIsFetching(fetchingFilters = {}, queryClient) { 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; } export { useIsFetching }; //# sourceMappingURL=useIsFetching.js.map