@tanstack/query-core
Version:
The framework agnostic core that powers TanStack Query
34 lines • 843 B
JavaScript
// src/removable.ts
import { timeoutManager } from "./timeoutManager.js";
import { environmentManager } from "./environmentManager.js";
import { isValidTimeout } from "./utils.js";
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 ?? (environmentManager.isServer() ? Infinity : 5 * 60 * 1e3)
);
}
clearGcTimeout() {
if (this.#gcTimeout) {
timeoutManager.clearTimeout(this.#gcTimeout);
this.#gcTimeout = void 0;
}
}
};
export {
Removable
};
//# sourceMappingURL=removable.js.map