All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.infinite.index.d.ts Maven / Gradle / Ivy

The newest version!
import { Arguments, BareFetcher, SWRConfiguration, SWRResponse, StrictTupleKey, MutatorCallback, MutatorOptions, Middleware } from 'swr/_internal';

type FetcherResponse = Data | Promise;
type SWRInfiniteFetcher = KeyLoader extends (...args: any[]) => any ? ReturnType extends infer T | null | false | undefined ? (args: T) => FetcherResponse : never : never;
type SWRInfiniteKeyLoader = (index: number, previousPageData: Data | null) => Args;
interface SWRInfiniteCompareFn {
    (a: Data | undefined, b: Data | undefined): boolean;
    (a: Data[] | undefined, b: Data[] | undefined): boolean;
}
interface SWRInfiniteConfiguration = BareFetcher> extends Omit, 'compare'> {
    initialSize?: number;
    revalidateAll?: boolean;
    persistSize?: boolean;
    revalidateFirstPage?: boolean;
    parallel?: boolean;
    fetcher?: Fn;
    compare?: SWRInfiniteCompareFn;
}
interface SWRInfiniteRevalidateFn {
    (data: Data, key: Arguments): boolean;
}
type InfiniteKeyedMutator = (data?: Data | Promise | MutatorCallback, opts?: boolean | SWRInfiniteMutatorOptions) => Promise;
interface SWRInfiniteMutatorOptions extends Omit, 'revalidate'> {
    revalidate?: boolean | SWRInfiniteRevalidateFn;
}
interface SWRInfiniteResponse extends Omit, 'mutate'> {
    size: number;
    setSize: (size: number | ((_size: number) => number)) => Promise;
    mutate: InfiniteKeyedMutator;
}
interface SWRInfiniteHook {
     StrictTupleKey>(getKey: KeyLoader): SWRInfiniteResponse;
     StrictTupleKey>(getKey: KeyLoader, fetcher: SWRInfiniteFetcher | null): SWRInfiniteResponse;
     StrictTupleKey>(getKey: KeyLoader, config: SWRInfiniteConfiguration> | undefined): SWRInfiniteResponse;
     StrictTupleKey>(getKey: KeyLoader, fetcher: SWRInfiniteFetcher | null, config: SWRInfiniteConfiguration> | undefined): SWRInfiniteResponse;
    (getKey: SWRInfiniteKeyLoader): SWRInfiniteResponse;
    (getKey: SWRInfiniteKeyLoader, fetcher: BareFetcher | null): SWRInfiniteResponse;
    (getKey: SWRInfiniteKeyLoader, config: SWRInfiniteConfiguration> | undefined): SWRInfiniteResponse;
    (getKey: SWRInfiniteKeyLoader, fetcher: BareFetcher | null, config: SWRInfiniteConfiguration> | undefined): SWRInfiniteResponse;
}

declare const unstable_serialize: (getKey: SWRInfiniteKeyLoader) => string;

declare const infinite: Middleware;
declare const useSWRInfinite: SWRInfiniteHook;

export { type SWRInfiniteCompareFn, type SWRInfiniteConfiguration, type SWRInfiniteFetcher, type SWRInfiniteHook, type SWRInfiniteKeyLoader, type SWRInfiniteResponse, useSWRInfinite as default, infinite, unstable_serialize };




© 2015 - 2024 Weber Informatics LLC | Privacy Policy