UNPKG

vue2-request-utils

Version:

Vue 3 composition API for data fetching. This is a version for Vue 2 by using @vue/composition-api.

48 lines (47 loc) 2.26 kB
import { LoadMoreExtendsOption } from '../useLoadMore'; import { PaginationExtendsOption } from '../usePagination'; import { InjectionKey, Ref, WatchSource } from '@vue/composition-api'; import { State } from './createQuery'; export declare const GLOBAL_OPTIONS_PROVIDE_KEY: InjectionKey<GlobalOptions>; export declare const setGlobalOptions: (config: GlobalOptions) => void; export declare const getGlobalOptions: () => GlobalOptions; export declare const clearGlobalOptions: () => void; export interface GlobalOptions extends PaginationExtendsOption, LoadMoreExtendsOption { loadingDelay?: number; pollingInterval?: number; pollingWhenHidden?: boolean; pollingWhenOffline?: boolean; debounceInterval?: number; throttleInterval?: number; refreshOnWindowFocus?: boolean; refocusTimespan?: number; cacheTime?: number; staleTime?: number; manual?: boolean; errorRetryCount?: number; errorRetryInterval?: number; } export declare type BaseOptions<R, P extends unknown[]> = GlobalOptions & { defaultParams?: P; ready?: Ref<boolean>; initialData?: R; refreshDeps?: WatchSource<any>[]; cacheKey?: string; queryKey?: (...args: P) => string; onSuccess?: (data: R, params: P) => void; onError?: (error: Error, params: P) => void; }; declare const FRPlaceholderType: unique symbol; export declare type FRPlaceholderType = typeof FRPlaceholderType; export declare type FormatOptions<R, P extends unknown[], FR> = { formatResult: (data: R) => FR; onSuccess?: (data: FR extends FRPlaceholderType ? any : FR, params: P) => void; } & Omit<BaseOptions<FR, P>, 'onSuccess'>; export declare type MixinOptions<R, P extends unknown[], FR> = BaseOptions<R, P> | FormatOptions<R, P, FR>; export declare type Config<R, P extends unknown[]> = Omit<BaseOptions<R, P>, 'defaultParams' | 'manual' | 'ready' | 'refreshDeps' | 'queryKey'> & Required<Pick<BaseOptions<R, P>, 'loadingDelay' | 'pollingWhenHidden' | 'pollingWhenOffline' | 'refreshOnWindowFocus' | 'errorRetryCount' | 'errorRetryInterval'>> & { stopPollingWhenHiddenOrOffline: Ref<boolean>; initialAutoRunFlag: Ref<boolean>; formatResult?: (data: any) => R; updateCache: (state: State<R, P>) => void; }; export {};