1 | export declare type fetcherFn<Data> = (...args: any) => Data | Promise<Data>;
|
2 | export interface ConfigInterface<Data = any, Error = any, Fn extends fetcherFn<Data> = fetcherFn<Data>> {
|
3 | errorRetryInterval?: number;
|
4 | errorRetryCount?: number;
|
5 | loadingTimeout?: number;
|
6 | focusThrottleInterval?: number;
|
7 | dedupingInterval?: number;
|
8 | refreshInterval?: number;
|
9 | refreshWhenHidden?: boolean;
|
10 | refreshWhenOffline?: boolean;
|
11 | revalidateOnFocus?: boolean;
|
12 | revalidateOnMount?: boolean;
|
13 | revalidateOnReconnect?: boolean;
|
14 | shouldRetryOnError?: boolean;
|
15 | fetcher?: Fn;
|
16 | suspense?: boolean;
|
17 | initialData?: Data;
|
18 | onLoadingSlow?: (key: string, config: ConfigInterface<Data, Error>) => void;
|
19 | onSuccess?: (data: Data, key: string, config: ConfigInterface<Data, Error>) => void;
|
20 | onError?: (err: Error, key: string, config: ConfigInterface<Data, Error>) => void;
|
21 | onErrorRetry?: (err: Error, key: string, config: ConfigInterface<Data, Error>, revalidate: revalidateType, revalidateOpts: RevalidateOptionInterface) => void;
|
22 | compare?: (a: Data | undefined, b: Data | undefined) => boolean;
|
23 | }
|
24 | export interface RevalidateOptionInterface {
|
25 | retryCount?: number;
|
26 | dedupe?: boolean;
|
27 | }
|
28 | declare type keyFunction = () => string | any[] | null;
|
29 | export declare type keyInterface = keyFunction | string | any[] | null;
|
30 | export declare type updaterInterface<Data = any, Error = any> = (shouldRevalidate?: boolean, data?: Data, error?: Error, shouldDedupe?: boolean) => boolean | Promise<boolean>;
|
31 | export declare type triggerInterface = (key: keyInterface, shouldRevalidate?: boolean) => Promise<any>;
|
32 | declare type mutateCallback<Data = any> = (currentValue: Data) => Promise<Data> | Data;
|
33 | export declare type mutateInterface<Data = any> = (key: keyInterface, data?: Data | Promise<Data> | mutateCallback<Data>, shouldRevalidate?: boolean) => Promise<Data | undefined>;
|
34 | export declare type broadcastStateInterface<Data = any, Error = any> = (key: string, data: Data, error?: Error) => void;
|
35 | export declare type responseInterface<Data, Error> = {
|
36 | data?: Data;
|
37 | error?: Error;
|
38 | revalidate: () => Promise<boolean>;
|
39 | mutate: (data?: Data | Promise<Data> | mutateCallback<Data>, shouldRevalidate?: boolean) => Promise<Data | undefined>;
|
40 | isValidating: boolean;
|
41 | };
|
42 | export declare type revalidateType = (revalidateOpts: RevalidateOptionInterface) => Promise<boolean>;
|
43 | export declare type pagesWithSWRType<Data, Error> = (swr: responseInterface<Data, Error>) => responseInterface<Data, Error>;
|
44 | export declare type pagesPropsInterface<Offset, Data, Error> = {
|
45 | offset: Offset;
|
46 | withSWR: pagesWithSWRType<Data, Error>;
|
47 | };
|
48 | export declare type pageComponentType<Offset, Data, Error> = (props: pagesPropsInterface<Offset, Data, Error>) => any;
|
49 | export declare type pageOffsetMapperType<Offset, Data, Error> = (SWR: responseInterface<Data, Error>, index: number) => Offset;
|
50 | export declare type pagesResponseInterface<Data, Error> = {
|
51 | pages: any;
|
52 | pageCount: number;
|
53 | pageSWRs: responseInterface<Data, Error>[];
|
54 | isLoadingMore: boolean;
|
55 | isReachingEnd: boolean;
|
56 | isEmpty: boolean;
|
57 | loadMore: () => void;
|
58 | };
|
59 | export declare type actionType<Data, Error> = {
|
60 | data?: Data;
|
61 | error?: Error;
|
62 | isValidating?: boolean;
|
63 | };
|
64 | export interface CacheInterface {
|
65 | get(key: keyInterface): any;
|
66 | set(key: keyInterface, value: any, shouldNotify?: boolean): any;
|
67 | keys(): string[];
|
68 | has(key: keyInterface): boolean;
|
69 | delete(key: keyInterface, shouldNotify?: boolean): void;
|
70 | clear(shouldNotify?: boolean): void;
|
71 | serializeKey(key: keyInterface): [string, any, string];
|
72 | subscribe(listener: cacheListener): () => void;
|
73 | }
|
74 | export declare type cacheListener = () => void;
|
75 | export {};
|