import { Alova, AlovaGenerics, FetchRequestState, Method, Progress, ReferingObject, StatesExport, StatesHook } from 'alova'; import { AlovaFetcherMiddleware, ExportedState, ProxyStateGetter, StateUpdater, UseHookConfig, UseHookExportedState, UseHookExposure } from '../general'; /** * specify the alova type * so that it can return the right states */ export type FetcherType> = { StatesExport: NonNullable extends StatesHook ? SE : any; }; /** useFetcher config export type */ export interface FetcherHookConfig extends UseHookConfig { /** * middleware */ middleware?: AlovaFetcherMiddleware; /** * whether to update the corresponding states of fetching method instance */ updateState?: boolean; } export interface UseFetchExportedState extends FetchRequestState< ExportedState, ExportedState, ExportedState, ExportedState > {} export interface UseFetchHookExposure extends UseFetchExportedState { fetch(matcher: Method>, ...args: any[]): Promise; update: StateUpdater, SE>; abort: UseHookExposure['abort']; onSuccess: UseHookExposure['onSuccess']; onError: UseHookExposure['onError']; onComplete: UseHookExposure['onComplete']; __proxyState: ProxyStateGetter>; __referingObj: ReferingObject; } /** * prefetch data * @example * ```js * const { loading, error, fetch } = useFetcher(); * const handleFetch = () => { * fetch(alova.Get('/api/profile')); * }; * ``` * @param config config * @returns reactive request data态operate function and event binding function */ export declare function useFetcher>( config?: FetcherHookConfig ): UseFetchHookExposure;