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
4
4
export type PromiseFn < T > = ( props : object , controller : AbortController ) => Promise < T >
5
5
export type DeferFn < T > = ( args : any [ ] , props : object , controller : AbortController ) => Promise < T >
6
6
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
+
7
17
export interface AsyncOptions < T > {
8
18
promise ?: Promise < T >
9
19
promiseFn ?: PromiseFn < T >
@@ -13,6 +23,16 @@ export interface AsyncOptions<T> {
13
23
initialValue ?: T
14
24
onResolve ?: ( data : T ) => void
15
25
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
16
36
[ prop : string ] : any
17
37
}
18
38
You can’t perform that action at this time.
0 commit comments