@tanstack/vue-query
Version:
Hooks for managing, caching and syncing asynchronous and remote data in Vue
47 lines (46 loc) • 1.75 kB
JavaScript
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/useQueryClient.ts
var useQueryClient_exports = {};
__export(useQueryClient_exports, {
useQueryClient: () => useQueryClient
});
module.exports = __toCommonJS(useQueryClient_exports);
var import_vue_demi = require("vue-demi");
var import_utils = require("./utils.cjs");
function useQueryClient(id = "") {
if (!(0, import_vue_demi.hasInjectionContext)()) {
throw new Error(
"vue-query hooks can only be used inside setup() function or functions that support injection context."
);
}
const key = (0, import_utils.getClientKey)(id);
const queryClient = (0, import_vue_demi.inject)(key);
if (!queryClient) {
throw new Error(
"No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library."
);
}
return queryClient;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
useQueryClient
});
//# sourceMappingURL=useQueryClient.cjs.map
;