import { AsyncState, AsyncMode, AsyncKey, AsyncRequestId } from './types'; /** * Extra properties that can be added to async state. * @internal */ export interface AsyncStateExtra { __key?: AsyncKey; __requestId?: AsyncRequestId; } /** * Create a frozen AsyncState with the specified status. * Users cannot modify properties directly - must use async actions. * * Overloads: * - asyncState("fresh", "idle") - Fresh idle state * - asyncState("fresh", "pending", extra?) - Fresh pending state * - asyncState("fresh", "success", data) - Fresh success state * - asyncState("fresh", "error", error, extra?) - Fresh error state * - asyncState("stale", "idle", data) - Stale idle state * - asyncState("stale", "pending", data, extra?) - Stale pending state * - asyncState("stale", "success", data) - Stale success state * - asyncState("stale", "error", data, error, extra?) - Stale error state */ export declare function asyncState(mode: "fresh", status: "idle"): AsyncState; export declare function asyncState(mode: "fresh", status: "pending", extra?: AsyncStateExtra): AsyncState; export declare function asyncState(mode: "fresh", status: "success", data: T): AsyncState; export declare function asyncState(mode: "fresh", status: "error", error: Error, extra?: AsyncStateExtra): AsyncState; export declare function asyncState(mode: "stale", status: "idle", data: T): AsyncState; export declare function asyncState(mode: "stale", status: "pending", data: T, extra?: AsyncStateExtra): AsyncState; export declare function asyncState(mode: "stale", status: "success", data: T): AsyncState; export declare function asyncState(mode: "stale", status: "error", data: T, error: Error, extra?: AsyncStateExtra): AsyncState; export declare namespace asyncState { var from: typeof asyncStateFrom; } /** * Create a new AsyncState based on a previous state, preserving mode and stale data. * Useful for deriving new states while maintaining the mode semantics. * * @example * // From success to pending (preserves mode and stale data) * const next = asyncState.from(prev, "pending"); * * // From pending to success * const next = asyncState.from(prev, "success", newData); * * // From any to error * const next = asyncState.from(prev, "error", new Error("failed")); */ export declare function asyncStateFrom(prev: AsyncState, status: "idle"): AsyncState; export declare function asyncStateFrom(prev: AsyncState, status: "pending"): AsyncState; export declare function asyncStateFrom(prev: AsyncState, status: "success", data: T): AsyncState; export declare function asyncStateFrom(prev: AsyncState, status: "error", error: Error): AsyncState; /** * Create a fresh mode async state (data undefined during loading/error). */ export declare function fresh(): AsyncState; /** * Create a stale mode async state with initial data. * Data is preserved during loading and error states. */ export declare function stale(): AsyncState; export declare function stale(initialData: T | undefined | null): AsyncState; //# sourceMappingURL=state.d.ts.map