import { Accessor } from 'solid-js'; interface UseAsyncStateReturnBase { state: Accessor; isReady: Accessor; isLoading: Accessor; error: Accessor; execute: (delay?: number, ...args: Params) => Promise; } type UseAsyncStateReturn = UseAsyncStateReturnBase & PromiseLike>; interface UseAsyncStateOptions { /** * Delay for executing the promise. In milliseconds. * * @default 0 */ delay?: number; /** * Execute the promise right after the function is invoked. * Will apply the delay if any. * * When set to false, you will need to execute it manually. * * @default true */ immediate?: boolean; /** * Callback when error is caught. */ onError?: (e: unknown) => void; /** * Callback when success is caught. */ onSuccess?: (data: T) => void; /** * Sets the state to initialState before executing the promise. * * This can be useful when calling the execute function more than once (for * example, to refresh data). When set to false, the current state remains * unchanged until the promise resolves. * * @default true */ resetOnExecute?: boolean; /** * * An error is thrown when executing the execute function * * @default false */ throwError?: boolean; } /** * Reactive async state. Will not block your setup function and will trigger changes once * the promise is ready. * * @see https://solidjs-use.github.io/solidjs-use/core/useAsyncState */ declare function useAsyncState(promise: Promise | ((...args: Params) => Promise), initialState: Data, options?: UseAsyncStateOptions): UseAsyncStateReturn; export { UseAsyncStateOptions, UseAsyncStateReturn, UseAsyncStateReturnBase, useAsyncState };