/** * EventualResult - A utility for the "stale-while-revalidate" pattern * * Returns cached data immediately, optionally refreshes in background. */ type EventualResult = { readonly current: TData; readonly fresh: Promise | null; readonly isStale: boolean; }; /** * Create an EventualResult from current data and optional fresh promise */ declare const eventual: (current: TData, fresh: Promise | null) => EventualResult; /** * Create an EventualResult, lazily creating the fresh promise only when stale */ declare const eventualIf: (current: TData, isStale: boolean, getFresh: () => Promise) => EventualResult; /** * Transform both current and fresh values of an EventualResult */ declare const mapEventual: (result: EventualResult, fn: (value: TInput) => TOutput) => EventualResult; /** * Combine multiple EventualResults into a single EventualResult * * The combined result is stale if any input is stale. * The fresh promise resolves when all stale inputs have refreshed. */ declare const combineEventual: >>(results: TResults) => EventualResult<{ [K in keyof TResults]: TResults[K]["current"]; }>; export { eventual, eventualIf, mapEventual, combineEventual }; export type { EventualResult }; //# sourceMappingURL=eventual.d.ts.map