File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,16 @@ export type AsyncChildren<T> = ((state: AsyncState<T>) => React.ReactNode) | Rea
44export type PromiseFn < T > = ( props : object , controller : AbortController ) => Promise < T >
55export type DeferFn < T > = ( args : any [ ] , props : object , controller : AbortController ) => Promise < T >
66
7+ interface AbstractAction {
8+ type : string
9+ meta : { counter : number ; [ meta : string ] : any }
10+ }
11+ export type Start = AbstractAction & { type : "start" ; payload : ( ) => Promise < void > }
12+ export type Cancel = AbstractAction & { type : "cancel" }
13+ export type Fulfill < T > = AbstractAction & { type : "fulfill" ; payload : T }
14+ export type Reject = AbstractAction & { type : "reject" ; payload : Error ; error : true }
15+ export type AsyncAction < T > = Start | Cancel | Fulfill < T > | Reject
16+
717export interface AsyncOptions < T > {
818 promise ?: Promise < T >
919 promiseFn ?: PromiseFn < T >
@@ -13,6 +23,16 @@ export interface AsyncOptions<T> {
1323 initialValue ?: T
1424 onResolve ?: ( data : T ) => void
1525 onReject ?: ( error : Error ) => void
26+ reducer ?: (
27+ state : AsyncState < T > ,
28+ action : AsyncAction < T > ,
29+ internalReducer : ( state : AsyncState < T > , action : AsyncAction < T > ) => AsyncState < T >
30+ ) => AsyncState < T >
31+ dispatcher ?: (
32+ action : AsyncAction < T > ,
33+ internalDispatch : ( action : AsyncAction < T > ) => void ,
34+ props : object
35+ ) => void
1636 [ prop : string ] : any
1737}
1838
You can’t perform that action at this time.
0 commit comments