UNPKG

@tanstack/vue-query

Version:

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

52 lines (51 loc) 2.03 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/useIsFetching.ts var useIsFetching_exports = {}; __export(useIsFetching_exports, { useIsFetching: () => useIsFetching }); module.exports = __toCommonJS(useIsFetching_exports); var import_vue_demi = require("vue-demi"); var import_useQueryClient = require("./useQueryClient.cjs"); function useIsFetching(fetchingFilters = {}, queryClient) { if (process.env.NODE_ENV === "development") { if (!(0, import_vue_demi.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 || (0, import_useQueryClient.useQueryClient)(); const isFetching = (0, import_vue_demi.ref)(); const listener = () => { isFetching.value = client.isFetching(fetchingFilters); }; const unsubscribe = client.getQueryCache().subscribe(listener); (0, import_vue_demi.watchEffect)(listener); (0, import_vue_demi.onScopeDispose)(() => { unsubscribe(); }); return isFetching; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { useIsFetching }); //# sourceMappingURL=useIsFetching.cjs.map