@spicy-ui/core
Version:
A themable and extensible React UI library, ready to use out of the box
24 lines (23 loc) • 748 B
TypeScript
/**
* util for async searchable story
* this is not published in package
*/
interface AsyncState<Data = any, Error = any> {
status?: 'idle' | 'pending' | 'rejected' | 'resolved';
data?: Data;
error?: Error;
}
export declare function useAsync<Data = any, Error = any>(initialState?: AsyncState<Data, Error>): {
isIdle: boolean;
isLoading: boolean;
isError: boolean;
isSuccess: boolean;
setData: (nextData?: Data | undefined) => void;
setError: (nextError: Error) => void;
error: Error | undefined;
status: "idle" | "pending" | "rejected" | "resolved" | undefined;
data: Data | undefined;
run: (promise: Promise<any>) => Promise<any>;
reset: () => void;
};
export {};