1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | interface RequestProps<T = any> {
|
9 | data: T;
|
10 | }
|
11 | type ExecProps<T = any> = {
|
12 | service: (event?: import('.').EventSend<T>) => Promise<any>;
|
13 | onSuccess?: (<P = T>(data: any) => P) | ((data: any) => void);
|
14 | onError?: (e: any) => void;
|
15 | onAlways?: () => void;
|
16 | };
|
17 |
|
18 | type UseRequest<T = any> = {
|
19 | isEmpty: boolean;
|
20 | loading: boolean;
|
21 | data: T;
|
22 | exec: (options: ExecProps<T>) => void;
|
23 | query: (key?: string, defaultValue?: any) => any;
|
24 | setQuery: (value: any | ((obj: any) => any)) => void;
|
25 | clear: (clean?: boolean) => void;
|
26 | cancel: () => void;
|
27 | };
|
28 |
|
29 | export default function useRequest<T>(props: RequestProps<T>): UseRequest<T>;
|