1 | import type { DependencyList } from 'react';
|
2 | import type { BasicTarget } from '../utils/domTarget';
|
3 | export type Data = {
|
4 | list: any[];
|
5 | [key: string]: any;
|
6 | };
|
7 | export type Service<TData extends Data> = (currentData?: TData) => Promise<TData>;
|
8 | export interface InfiniteScrollResult<TData extends Data> {
|
9 | data: TData;
|
10 | loading: boolean;
|
11 | loadingMore: boolean;
|
12 | noMore: boolean;
|
13 | loadMore: () => void;
|
14 | loadMoreAsync: () => Promise<TData>;
|
15 | reload: () => void;
|
16 | reloadAsync: () => Promise<TData>;
|
17 | cancel: () => void;
|
18 | mutate: (data?: TData) => void;
|
19 | }
|
20 | export interface InfiniteScrollOptions<TData extends Data> {
|
21 | target?: BasicTarget<Element | Document>;
|
22 | isNoMore?: (data?: TData) => boolean;
|
23 | threshold?: number;
|
24 | manual?: boolean;
|
25 | reloadDeps?: DependencyList;
|
26 | onBefore?: () => void;
|
27 | onSuccess?: (data: TData) => void;
|
28 | onError?: (e: Error) => void;
|
29 | onFinally?: (data?: TData, e?: Error) => void;
|
30 | }
|