import { Ref, WatchSource } from "vue"; import type { CachedData } from "./utils/cache"; import Fetch from "./Fetch"; export declare type Service = (...args: TParams) => Promise; export declare type Subscribe = () => void; export interface FetchState { loading: boolean; params?: TParams; data?: TData; error?: Error | unknown; } export interface PluginReturn { onBefore?: (params: TParams) => ({ stopNow?: boolean; returnNow?: boolean; } & Partial>) | void; onRequest?: (service: Service, params: TParams) => { servicePromise?: Promise; }; onSuccess?: (data: TData, params: TParams) => void; onError?: (e: Error, params: TParams) => void; onFinally?: (params: TParams, data?: TData, e?: Error) => void; onCancel?: () => void; onMutate?: (data: TData) => void; } export interface Options { manual?: boolean; onBefore?: (params: TParams) => void; onSuccess?: (data: TData, params: TParams) => void; onError?: (e: Error, params: TParams) => void; onFinally?: (params: TParams, data?: TData, e?: Error) => void; defaultParams?: TParams; refreshDeps?: WatchSource[] | any; refreshDepsAction?: () => void; loadingDelay?: number | Ref; pollingInterval?: Ref | number; pollingWhenHidden?: boolean; refreshOnWindowFocus?: Ref | boolean; focusTimespan?: number; debounceWait?: number; debounceLeading?: Ref; debounceTrailing?: Ref; debounceMaxWait?: Ref; throttleWait?: number; throttleLeading?: Ref; throttleTrailing?: Ref; cacheKey?: string; cacheTime?: number; staleTime?: number; setCache?: (data: CachedData) => void; getCache?: (params: TParams) => CachedData | undefined; retryCount?: number; retryInterval?: number; ready?: Ref | boolean; [x: string]: any; } export declare type Plugin = { (fetchInstance: Fetch, options: Options): PluginReturn; onInit?: (options: Options) => Partial>; }; export interface Result { loading: Ref; data?: Ref; error?: Ref; params: Ref; cancel: Fetch["cancel"]; refresh: Fetch["refresh"]; refreshAsync: Fetch["refreshAsync"]; run: Fetch["run"]; runAsync: Fetch["runAsync"]; mutate: Fetch["mutate"]; } export declare type Timeout = ReturnType; export declare type Interval = ReturnType;