Server: Phase 2 (REVIEW not respected yet)
This commit is contained in:
1 parent
5d16ded553
commit
142b47674d
4271 files changed
+1203269
No files matched your search
+23
@@ -0,0 +1,23 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
||||
//#region src/suspense.ts
|
||||
const defaultThrowOnError = (_error, query) => query.state.data === void 0;
|
||||
const ensureSuspenseTimers = (defaultedOptions) => {
|
||||
if (defaultedOptions.suspense) {
|
||||
const MIN_SUSPENSE_TIME_MS = 1e3;
|
||||
const clamp = (value) => value === "static" ? value : Math.max(value ?? MIN_SUSPENSE_TIME_MS, MIN_SUSPENSE_TIME_MS);
|
||||
const originalStaleTime = defaultedOptions.staleTime;
|
||||
defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime);
|
||||
if (typeof defaultedOptions.gcTime === "number") defaultedOptions.gcTime = Math.max(defaultedOptions.gcTime, MIN_SUSPENSE_TIME_MS);
|
||||
}
|
||||
};
|
||||
const shouldSuspend = (defaultedOptions, result) => (defaultedOptions === null || defaultedOptions === void 0 ? void 0 : defaultedOptions.suspense) && result.isPending;
|
||||
const fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
|
||||
errorResetBoundary.clearReset();
|
||||
});
|
||||
//#endregion
|
||||
exports.defaultThrowOnError = defaultThrowOnError;
|
||||
exports.ensureSuspenseTimers = ensureSuspenseTimers;
|
||||
exports.fetchOptimistic = fetchOptimistic;
|
||||
exports.shouldSuspend = shouldSuspend;
|
||||
|
||||
//# sourceMappingURL=suspense.cjs.map
|
||||
Reference in new issue
Block a user