solid-awesome-hooks
Version:
A collection of awesome hooks for solid-js
15 lines (14 loc) • 568 B
TypeScript
import { type Accessor, type Setter } from "solid-js";
type ActionState = "pending" | "resolved" | "errored" | "ready";
type TryAction = <T>(action: () => Promise<T>) => Promise<T>;
export type AsyncAction = {
/** Pass an async function here */
try: TryAction;
state: Accessor<ActionState>;
errorMessage: Accessor<string | undefined>;
setErrorMessage: Setter<string | undefined>;
/** Resets progress, error states and error message */
reset: VoidFunction;
};
export declare const useAsyncAction: () => AsyncAction;
export {};