@rocketmakers/api-swr
Version:
Rocketmakers front-end library for parsing a generated Typescript API client into a set of configurable React hooks for fetching and mutating data.
51 lines (50 loc) • 3.07 kB
TypeScript
import { type ScopedMutator } from 'swr/_internal';
/**
* A hook to get the global mutate function from `swr` and a custom mutate function for infinite queries
* @returns The global mutate function and the custom mutate function for infinite queries
*/
export declare const useCacheManager: () => {
errorRetryInterval: number;
errorRetryCount?: number | undefined;
/**
* A function to perform a simple invalidation and request new data for a given key
* Designed for use with infinite queries, the key only needs to be the `cacheKey` of the endpoint, the `startsWith` invalidator is not needed here.
* This is just a wrapper around `mutate` with only the key argument, added for semantic clarity
* @param key The key to invalidate
* @returns The result of the SWR mutation
*/
loadingTimeout: number;
focusThrottleInterval: number;
dedupingInterval: number;
refreshInterval?: number | ((latestData: any) => number) | undefined;
refreshWhenHidden?: boolean | undefined;
refreshWhenOffline?: boolean | undefined;
revalidateOnFocus: boolean;
revalidateOnReconnect: boolean;
revalidateOnMount?: boolean | undefined;
revalidateIfStale: boolean;
shouldRetryOnError: boolean | ((err: any) => boolean);
keepPreviousData?: boolean | undefined;
suspense?: boolean | undefined;
fallbackData?: any;
fetcher?: import("swr/dist/_internal/types").BareFetcher<unknown> | undefined;
use?: import("swr/dist/_internal/types").Middleware[] | undefined;
fallback: {
[key: string]: any;
};
isPaused: () => boolean;
onLoadingSlow: (key: string, config: Readonly<import("swr/dist/_internal/types").PublicConfiguration<any, any, import("swr/dist/_internal/types").BareFetcher<unknown>>>) => void;
onSuccess: (data: any, key: string, config: Readonly<import("swr/dist/_internal/types").PublicConfiguration<any, any, import("swr/dist/_internal/types").BareFetcher<unknown>>>) => void;
onError: (err: any, key: string, config: Readonly<import("swr/dist/_internal/types").PublicConfiguration<any, any, import("swr/dist/_internal/types").BareFetcher<unknown>>>) => void;
onErrorRetry: (err: any, key: string, config: Readonly<import("swr/dist/_internal/types").PublicConfiguration<any, any, import("swr/dist/_internal/types").BareFetcher<unknown>>>, revalidate: import("swr/dist/_internal/types").Revalidator, revalidateOpts: Required<import("swr/dist/_internal/types").RevalidatorOptions>) => void;
onDiscarded: (key: string) => void;
compare: (a: any, b: any) => boolean;
isOnline: () => boolean;
isVisible: () => boolean;
mutate: ScopedMutator;
mutateInfinite: (params_0: string, data?: unknown, opts?: boolean | import("swr/dist/_internal/types").MutatorOptions<unknown, unknown> | undefined) => Promise<void>;
invalidate: (key: Parameters<ScopedMutator>[0]) => Promise<any>;
invalidateInfinite: (key: string) => Promise<void>;
cache: import("swr/dist/_internal/types").Cache<any>;
clearAll: () => Promise<void>;
};