-
Notifications
You must be signed in to change notification settings - Fork 67
/
index.d.ts
82 lines (68 loc) · 2.78 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
declare module 'redux-query-react' {
import React from 'react';
import {
ActionPromiseValue,
Entities,
QueriesState,
QueryConfig,
QueryState,
QueriesSelector,
} from 'redux-query';
export type QueryConfigFactory<TEntities = Entities, TArgs = never> = (
...args: TArgs
) => QueryConfig<TEntities>;
export type QueryConfigsFactory<TEntities = Entities, TArgs = never> = (
...args: TArgs
) => QueryConfig<TEntities> | QueryConfig<TEntities>[];
export interface ConnectRequestOptions {
forwardRef?: boolean;
pure?: boolean;
}
export type ForceRequestCallback<TEntities = Entities> = () => Promise<
ActionPromiseValue<TEntities>
> | void;
export type ForceRequestsCallback = () => void;
export interface WithForceRequest<TEntities = Entities> {
forceRequest: ForceRequestCallback<TEntities>;
}
export type ConnectRequestWrapper<TProps extends WithForceRequest> = (
WrappedComponent: React.ComponentType<TProps>,
) => React.ComponentType<Omit<TProps, 'forceRequest'>>;
export type RequestConnector<
TEntities = Entities,
TProps extends WithForceRequest<TEntities> = WithForceRequest<TEntities>
> = (
mapPropsToConfigs: QueryConfigsFactory<TEntities>,
options?: ConnectRequestOptions,
) => ConnectRequestWrapper<TProps>;
export interface ProviderProps {
queriesSelector: QueriesSelector;
children?: React.ReactNode;
}
export type ReduxQueryProvider = React.ComponentType<ProviderProps>;
export type ActionPromise<TEntities = Entities> = Promise<ActionPromiseValue<TEntities>>;
type RunMutation<TEntities = Entities, TArgs = never> = (
...args: TArgs
) => ActionPromise<TEntities>;
type RunRequest<TEntities = Entities, TArgs = never> = (
...args: TArgs
) => ActionPromise<TEntities>;
export type UseRequestHook = <TEntities = Entities>(
queryConfig: QueryConfig<TEntities> | null | undefined,
) => [QueryState, ForceRequestCallback<TEntities>];
export type UseRequestsHook = <TEntities = Entities>(
queryConfigs: Array<QueryConfig<TEntities> | null | undefined> | null | undefined,
) => [QueryState, ForceRequestsCallback];
export type UseRequestOnDemandHook = <TEntities = Entities, TArgs = never>(
createQueryConfig: QueryConfigFactory<TEntities, TArgs>,
) => [QueryState, RunRequest<TEntities, TArgs>];
export type UseMutationHook = <TEntities = Entities, TArgs = never>(
createQueryConfig: QueryConfigFactory<TEntities, TArgs>,
) => [QueryState, RunMutation<TEntities, TArgs>];
export const connectRequest: RequestConnector;
export const Provider: ReduxQueryProvider;
export const useRequest: UseRequestHook;
export const useRequestOnDemand: UseRequestOnDemandHook;
export const useRequests: UseRequestsHook;
export const useMutation: UseMutationHook;
}