Skip to main content

Interface: UseAsyncOptions<T, A, E>

Defined in: use-async.ts:23

Options for useAsync.

Type Parameters​

T​

T

The type of data the async function resolves with.

A​

A extends unknown[]

The argument list of the async function.

E​

E = unknown

The type of error the async function rejects with.

Properties​

args?​

optional args?: A

Defined in: use-async.ts:30

Arguments for the immediate run on mount.


immediate?​

optional immediate?: boolean

Defined in: use-async.ts:28

Run the async function once on mount, with UseAsyncOptions.args. Default is false. Later runs are always triggered with run.


initialData?​

optional initialData?: T

Defined in: use-async.ts:32

The data before the first success, and after reset. Default is undefined.


onError?​

optional onError?: (error, args) => void

Defined in: use-async.ts:36

Called with the error and the arguments when a run fails. Ignored for stale runs and after unmount.

Parameters​

error​

E

args​

A

Returns​

void


onSuccess?​

optional onSuccess?: (data, args) => void

Defined in: use-async.ts:34

Called with the result and the arguments when a run succeeds. Ignored for stale runs and after unmount.

Parameters​

data​

T

args​

A

Returns​

void