@tanstack/query-core
Version:
The framework agnostic core that powers TanStack Query
42 lines (41 loc) • 927 B
JavaScript
import {
__privateAdd,
__privateGet,
__privateSet
} from "./chunk-WPSKCR32.js";
// src/removable.ts
import { isServer, isValidTimeout } from "./utils.js";
var _gcTimeout;
var Removable = class {
constructor() {
__privateAdd(this, _gcTimeout, void 0);
}
destroy() {
this.clearGcTimeout();
}
scheduleGc() {
this.clearGcTimeout();
if (isValidTimeout(this.gcTime)) {
__privateSet(this, _gcTimeout, setTimeout(() => {
this.optionalRemove();
}, this.gcTime));
}
}
updateGcTime(newGcTime) {
this.gcTime = Math.max(
this.gcTime || 0,
newGcTime ?? (isServer ? Infinity : 5 * 60 * 1e3)
);
}
clearGcTimeout() {
if (__privateGet(this, _gcTimeout)) {
clearTimeout(__privateGet(this, _gcTimeout));
__privateSet(this, _gcTimeout, void 0);
}
}
};
_gcTimeout = new WeakMap();
export {
Removable
};
//# sourceMappingURL=removable.js.map