import type { AtomType } from "../Mutables/atom/atom"; /** * Represents the current status of an async action */ export type AsyncActionStatus = "init" | "loading" | "success" | "error"; /** * Configuration options for async actions */ export type AsyncFetchOptions = { /** Cache duration in milliseconds. Default: undefined (infinite — cache never expires) */ cacheDuration?: number; /** Maximum number of cache entries. Uses LRU eviction when exceeded. Default: 10 */ cacheLimit?: number; /** Polling interval in milliseconds. Default: 5000 */ pollInterval?: number; allowInRestrictedContext?: boolean; }; /** * Interceptor called before the async action executes. * Receives `next` (the original fn) and the call arguments. * Must call `next` and return its result. */ export type AsyncActionBeforeInterceptor Promise> = (next: T, ...args: Parameters) => ReturnType; /** * Interceptor called after the async action resolves. * Receives the resolved result and must return a (possibly modified) result. */ export type AsyncActionAfterInterceptor Promise> = (result: Awaited>) => Awaited>; /** * Return type for asyncAction - combines the original function with state management */ export type AsyncActionReturnType Promise> = T & { /** Atom containing the result data */ data: AtomType> | null>; /** Atom containing any error that occurred */ error: AtomType; /** Atom indicating if action is currently loading */ isLoading: AtomType; /** Atom containing current action status */ status: AtomType; /** The AbortController for the current in-flight operation, or null if idle */ abortController: AbortController | null; /** Get the underlying action function */ val: () => T; /** Replace the action function */ set: (fn: T) => void; /** Cancel the current operation */ cancel: () => void; /** Subscribe to action completion events */ subscribe: (fn: () => void, onSuccessOrError?: boolean) => () => void; /** Call action and cache the result */ cache: T; /** Clear cached results */ clearCache: (...args: any[]) => void; /** Start polling with given arguments */ startPolling: (...args: Parameters) => void; /** Stop polling */ stopPolling: () => void; /** Set a before-interceptor */ interceptBefore: (interceptor: AsyncActionBeforeInterceptor) => void; /** Set an after-interceptor */ interceptAfter: (interceptor: AsyncActionAfterInterceptor) => void; }; /** * Subscriber configuration for async action events */ export type Subscriber = { /** Callback function to execute */ fn: () => void; /** Filter: true = success only, false = error only, undefined = both */ filter?: boolean; }; export type AsyncActionOptions = AsyncFetchOptions; //# sourceMappingURL=asyncActionTypes.d.ts.map