UNPKG

@tanstack/query-core

Version:

The framework agnostic core that powers TanStack Query

29 lines (28 loc) 767 B
import { timeoutManager } from "./timeoutManager.js"; import { isValidTimeout } from "./utils.js"; import { isServer } from "./environmentManager.js"; //#region src/removable.ts var Removable = class { #gcTimeout; destroy() { this.clearGcTimeout(); } scheduleGc() { this.clearGcTimeout(); if (isValidTimeout(this.gcTime)) this.#gcTimeout = timeoutManager.setTimeout(() => { this.optionalRemove(); }, this.gcTime); } updateGcTime(newGcTime) { this.gcTime = Math.max(this.gcTime || 0, newGcTime ?? (isServer() ? Infinity : 3e5)); } clearGcTimeout() { if (this.#gcTimeout !== void 0) { timeoutManager.clearTimeout(this.#gcTimeout); this.#gcTimeout = void 0; } } }; //#endregion export { Removable }; //# sourceMappingURL=removable.js.map