File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-async-hook" ,
3
- "version" : " 2.1 .0" ,
3
+ "version" : " 2.2 .0" ,
4
4
"description" : " Async hook" ,
5
5
"author" : " Sébastien Lorber" ,
6
6
"license" : " MIT" ,
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ const normalizeOptions = <R>(
60
60
61
61
type UseAsyncStateResult < R > = {
62
62
value : AsyncState < R > ;
63
+ set : ( value : AsyncState < R > ) => void ;
63
64
setLoading : ( ) => void ;
64
65
setResult : ( r : R ) => void ;
65
66
setError : ( e : Error ) => void ;
@@ -70,6 +71,7 @@ const useAsyncState = <R extends {}>(
70
71
const [ value , setValue ] = useState < AsyncState < R > > ( InitialAsyncState ) ;
71
72
return {
72
73
value,
74
+ set : setValue ,
73
75
setLoading : ( ) => setValue ( options . setLoading ( value ) ) ,
74
76
setResult : result => setValue ( options . setResult ( result , value ) ) ,
75
77
setError : error => setValue ( options . setError ( error , value ) ) ,
@@ -102,6 +104,7 @@ const useCurrentPromise = <R>(): UseCurrentPromiseReturn<R> => {
102
104
} ;
103
105
104
106
export type UseAsyncReturn < R > = AsyncState < R > & {
107
+ set : ( value : AsyncState < R > ) => void ;
105
108
execute : ( ) => Promise < R > ;
106
109
currentPromise : Promise < R > | null ;
107
110
} ;
@@ -154,6 +157,7 @@ export const useAsync = <R, Args extends any[]>(
154
157
155
158
return {
156
159
...AsyncState . value ,
160
+ set : AsyncState . set ,
157
161
execute : executeAsyncOperation ,
158
162
currentPromise : CurrentPromise . get ( ) ,
159
163
} ;
You can’t perform that action at this time.
0 commit comments