import { SWR, SWRKey, SWRMutateValue, SWROptions, SWRMutateOptions, SWRRevalidateOptions, CacheClearOptions } from 'swrev'; import { Ref, ComputedRef, WatchStopHandle } from 'vue'; export interface SWRResponse { data: Ref; error: Ref; mutate: (value: D, ops?: Partial> | undefined) => void; revalidate: (ops?: Partial> | undefined) => void; clear: (ops?: Partial | undefined) => void; unsubscribe: WatchStopHandle; isLoading: ComputedRef; isValid: ComputedRef; promise: Promise>; } export interface SWRSuspenseResponse { data: Ref; mutate: (value: D, ops?: Partial> | undefined) => void; revalidate: (ops?: Partial> | undefined) => void; clear: (ops?: Partial | undefined) => void; unsubscribe: WatchStopHandle; } export declare type SuspenseSWRBuilder = (key: SWRKey, options?: Partial>) => Promise>; export declare class VSWR extends SWR { /** * Use the SWR with a vue application. * Queries the data. */ query(key?: SWRKey | (() => SWRKey | undefined), options?: Partial>): SWRResponse; /** * Query with suspense support. */ querySuspense(key?: SWRKey | (() => SWRKey | undefined), options?: Partial>): Promise>; } /** * Creates a mew SWR instance and exports basic methods to * work with without the need for method calling. */ export declare const createSWR: (options?: Partial> | undefined) => VSWR; /** * Default SWR instance. Can be replaced * with the `createDefaultSWR` function. */ export declare let swr: VSWR; /** * Creates and sets a default SWR instance given * the options. */ export declare const createDefaultSWR: (options?: Partial> | undefined) => VSWR; /** * Gets the data of the given key. Keep in mind * this data will be stale and revalidate in the background * unless specified otherwise. */ export declare const subscribeData: (key: SWRKey | undefined, onData: (value: D) => any) => () => void; /** * Subscribes to errors on the given key. */ export declare const subscribeErrors: (key: SWRKey | undefined, onError: (error: E) => any) => () => void; /** * Gets the current cached data of the given key. * This does not trigger any revalidation nor mutation * of the data. * - If the data has never been validated * (there is no cache) it will return undefined. * - If the item is pending to resolve (there is a request * pending to resolve) it will return undefined. */ export declare const get: (key?: string | undefined) => D | undefined; /** * Gets an element from the cache. The difference * with the get is that this method returns a promise * that will resolve the the value. If there's no item * in the cache, it will wait for it before resolving. */ export declare const getWait: (key: SWRKey) => Promise; /** * Use a SWR value given the key and * subscribe to future changes. */ export declare const subscribe: (key: SWRKey | undefined | (() => SWRKey | undefined), onData: (value: D) => void, onError: (error: E) => void, options?: Partial> | undefined) => { unsubscribe: () => void; }; /** * Use the SWR with a vue application. */ export declare const query: (key?: string | (() => SWRKey | undefined) | undefined, options?: Partial> | undefined) => SWRResponse; /** * Query with suspense support. */ export declare const querySuspense: (key?: string | (() => SWRKey | undefined) | undefined, options?: Partial> | undefined) => Promise>; /** * Mutates the data of a given key with a new value. * This is used to replace the cache contents of the * given key manually. */ export declare const mutate: (key?: string | undefined, value?: SWRMutateValue | undefined, options?: Partial> | undefined) => void; /** * Revalidates the key and mutates the cache if needed. */ export declare const revalidate: (key?: string | undefined, options?: Partial> | undefined) => void; /** * Clear the specified keys from the cache. If no keys * are specified, it clears all the cache keys. */ export declare const clear: (keys?: string | string[] | null | undefined, options?: Partial | undefined) => void;