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