UNPKG

@tanstack/query-core

Version:

The framework agnostic core that powers TanStack Query

44 lines (43 loc) 1.08 kB
import { __privateAdd, __privateGet, __privateSet } from "./chunk-PXG64RU4.js"; // src/removable.ts import { timeoutManager } from "./timeoutManager.js"; import { environmentManager } from "./environmentManager.js"; import { isValidTimeout } from "./utils.js"; var _gcTimeout; var Removable = class { constructor() { __privateAdd(this, _gcTimeout); } destroy() { this.clearGcTimeout(); } scheduleGc() { this.clearGcTimeout(); if (isValidTimeout(this.gcTime)) { __privateSet(this, _gcTimeout, timeoutManager.setTimeout(() => { this.optionalRemove(); }, this.gcTime)); } } updateGcTime(newGcTime) { this.gcTime = Math.max( this.gcTime || 0, newGcTime ?? (environmentManager.isServer() ? Infinity : 5 * 60 * 1e3) ); } clearGcTimeout() { if (__privateGet(this, _gcTimeout)) { timeoutManager.clearTimeout(__privateGet(this, _gcTimeout)); __privateSet(this, _gcTimeout, void 0); } } }; _gcTimeout = new WeakMap(); export { Removable }; //# sourceMappingURL=removable.js.map