@@ -17,7 +17,9 @@ declare interface CachedData<TData = any, TParams = any> {
17
17
time : number ;
18
18
}
19
19
20
- export declare const clearCache : ( key ?: string | string [ ] ) => void ;
20
+ export declare const clearUseRequestCache : ( key ?: string | string [ ] ) => void ;
21
+
22
+ export declare function createUseRequest < TData , TParams extends unknown [ ] = unknown [ ] , PluginsOptions extends UseRequestPlugin < TData , TParams > [ ] = UseRequestPlugin < TData , TParams > [ ] > ( service : UseRequestService < TData , TParams > , options ?: UseRequestOptions < TData , TParams , PluginsOptions extends ( infer P ) [ ] ? P extends UseRequestPlugin < TData , TParams , infer R > ? R : any : any > , plugins ?: PluginsOptions ) : useRequestResult < TData , TParams > ;
21
23
22
24
declare interface DebounceOptions {
23
25
/**
@@ -66,20 +68,26 @@ declare const eventEmitterOverall: EventEmitter<unknown>;
66
68
declare class Fetch < TData , TParams extends unknown [ ] = any > {
67
69
serviceRef : Ref < UseRequestService < TData , TParams > > ;
68
70
options : UseRequestOptions < TData , TParams , any > ;
69
- setUpdateData : ( s : any , key ?: keyof UseRequestFetchState < TData , TParams > ) => void ;
71
+ setUpdateData : ( currentState : unknown , key ?: keyof UseRequestFetchState < TData , TParams > ) => void ;
70
72
initState : Partial < UseRequestFetchState < TData , TParams > > ;
71
73
pluginImpls : UseRequestPluginReturn < TData , TParams > [ ] | undefined ;
72
74
count : number ;
73
75
state : UseRequestFetchState < TData , TParams > ;
74
- constructor ( serviceRef : Ref < UseRequestService < TData , TParams > > , options : UseRequestOptions < TData , TParams , any > , setUpdateData : ( s : any , key ?: keyof UseRequestFetchState < TData , TParams > ) => void , initState ?: Partial < UseRequestFetchState < TData , TParams > > ) ;
75
- setState ( s ?: Partial < UseRequestFetchState < TData , TParams > > ) : void ;
76
+ constructor ( serviceRef : Ref < UseRequestService < TData , TParams > > , options : UseRequestOptions < TData , TParams , any > , setUpdateData : ( currentState : unknown , key ?: keyof UseRequestFetchState < TData , TParams > ) => void , initState ?: Partial < UseRequestFetchState < TData , TParams > > ) ;
77
+ setState ( currentState ?: Partial < UseRequestFetchState < TData , TParams > > ) : void ;
78
+ /**
79
+ * should rename
80
+ * @param data Result value `unknown`
81
+ * @param key Result key `data`| `params` | `loading`| `error`
82
+ */
83
+ setData ( data : unknown , key ?: keyof UseRequestFetchState < TData , TParams > | ( keyof UseRequestFetchState < TData , TParams > ) [ ] ) : void ;
76
84
/**
77
85
*
78
- * @param data Result value `any `
86
+ * @param data Result value `unknown `
79
87
* @param key Result key `data`| `params` | `loading`| `error`
80
88
*/
81
- setData ( data : any , key ?: keyof UseRequestFetchState < TData , TParams > | ( keyof UseRequestFetchState < TData , TParams > ) [ ] ) : void ;
82
- runPluginHandler ( event : keyof UseRequestPluginReturn < TData , TParams > , ...rest : any [ ] ) : any ;
89
+ setFetchState ( data : unknown , key ?: keyof UseRequestFetchState < TData , TParams > | ( keyof UseRequestFetchState < TData , TParams > ) [ ] ) : void ;
90
+ runPluginHandler ( event : keyof UseRequestPluginReturn < TData , TParams > , ...rest : unknown [ ] ) : any ;
83
91
runAsync ( ...params : TParams ) : Promise < TData > ;
84
92
run ( ...params : TParams ) : void ;
85
93
cancel ( ) : void ;
@@ -216,7 +224,7 @@ declare interface UseBooleanActions {
216
224
217
225
declare type UseBooleanResult = [ Ref < boolean > , UseBooleanActions ] ;
218
226
219
- export declare function useCookieState ( cookieKey : string , options ?: UseCookieStateOptions ) : readonly [ Ref < UseCookieStateType > , ( newValue : UseCookieStateType | ( ( prevState : UseCookieStateType ) => UseCookieStateType ) , newOptions ?: Cookies . CookieAttributes ) => void ] ;
227
+ export declare function useCookieState ( cookieKey : string , options ?: UseCookieStateOptions ) : readonly [ any , ( newValue : UseCookieStateType | ( ( prevState : UseCookieStateType ) => UseCookieStateType ) , newOptions ?: Cookies . CookieAttributes ) => void ] ;
220
228
221
229
declare interface UseCookieStateOptions extends Cookies . CookieAttributes {
222
230
defaultValue ?: UseCookieStateType | ( ( ) => UseCookieStateType ) ;
@@ -925,6 +933,8 @@ declare interface UseRequestPluginReturn<TData, TParams extends unknown[]> {
925
933
onMutate ?: ( data : TData ) => void ;
926
934
}
927
935
936
+ export declare function useRequestProvider ( config : UseRequestOptions < unknown , any , any > ) : void ;
937
+
928
938
declare interface useRequestResult < TData , TParams extends unknown [ ] > {
929
939
/**
930
940
* Is the service being executed.
@@ -990,7 +1000,7 @@ declare interface UseSetActions<T> {
990
1000
991
1001
export declare function useSetState < S extends Record < string , any > > ( initialState : UseSetStateType < S > ) : [
992
1002
DeepReadonly < UnwrapNestedRefs < [ S ] extends [ Ref < any > ] ? S : Ref < UnwrapRef < S > > > > ,
993
- ( patch : Record < string , any > ) => void
1003
+ ( patch : Record < string , any > , cover ?: boolean ) => void
994
1004
] ;
995
1005
996
1006
declare type UseSetStateType < S > = S | ( ( ) => S ) | Ref < S > | ( ( ) => Ref < S > ) ;
@@ -1090,7 +1100,7 @@ declare type UseSetStateType<S> = S | (() => S) | Ref<S> | (() => Ref<S>);
1090
1100
}
1091
1101
1092
1102
declare interface UseWebSocketResult {
1093
- latestMessage ? : Ref < WebSocketEventMap [ 'message' ] > ;
1103
+ latestMessage : Ref < WebSocketEventMap [ 'message' ] | undefined > ;
1094
1104
sendMessage ?: WebSocket [ 'send' ] ;
1095
1105
disconnect ?: ( ) => void ;
1096
1106
connect ?: ( ) => void ;
0 commit comments