File tree 1 file changed +25
-6
lines changed
1 file changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -43,12 +43,31 @@ export type AsyncStateStatus =
43
43
| 'success'
44
44
| 'error' ;
45
45
46
- export type AsyncState < R > = {
47
- status : AsyncStateStatus ;
48
- loading : boolean ;
49
- error : Error | undefined ;
50
- result : R | undefined ;
51
- } ;
46
+ export declare type AsyncState < R > =
47
+ | {
48
+ status : 'not-requested' ;
49
+ loading : false ;
50
+ result : undefined ;
51
+ error : undefined ;
52
+ }
53
+ | {
54
+ status : 'loading' ;
55
+ loading : true ;
56
+ error : undefined ;
57
+ result : undefined ;
58
+ }
59
+ | {
60
+ status : 'success' ;
61
+ loading : false ;
62
+ error : undefined ;
63
+ result : R ;
64
+ }
65
+ | {
66
+ status : 'error' ;
67
+ loading : false ;
68
+ error : Error ;
69
+ result : undefined ;
70
+ } ;
52
71
type SetLoading < R > = ( asyncState : AsyncState < R > ) => AsyncState < R > ;
53
72
type SetResult < R > = ( result : R , asyncState : AsyncState < R > ) => AsyncState < R > ;
54
73
type SetError < R > = ( error : Error , asyncState : AsyncState < R > ) => AsyncState < R > ;
You can’t perform that action at this time.
0 commit comments