/** * Request options for useRequest hook */ export type UseRequestOptions = { /** Whether to execute automatically on mount */ manual?: boolean; /** Default parameters for the request */ defaultParams?: TParameters; /** Refresh dependencies - triggers re-execution when changed */ refreshDeps?: unknown[]; /** Cache key for request deduplication */ cacheKey?: string; /** Cache time in milliseconds */ cacheTime?: number; /** Whether to refresh on window focus */ refreshOnWindowFocus?: boolean; /** Focus throttle time in milliseconds */ focusThrottleWait?: number; /** Whether to refresh on network reconnect */ refreshOnReconnect?: boolean; /** Polling interval in milliseconds */ pollingInterval?: number; /** Whether to stop polling when error occurs */ pollingWhenHidden?: boolean; /** Loading delay in milliseconds */ loadingDelay?: number; /** Retry configuration */ retry?: { count?: number; delay?: number | ((attempt: number) => number); }; /** Request debounce delay in milliseconds */ debounceWait?: number; /** Request throttle delay in milliseconds */ throttleWait?: number; /** Ready state - only execute when true */ ready?: boolean; /** onBefore callback */ onBefore?: (parameters: TParameters) => void; /** onSuccess callback */ onSuccess?: (data: TData, parameters: TParameters) => void; /** onError callback */ onError?: (error: Error, parameters: TParameters) => void; /** onFinally callback */ onFinally?: (parameters: TParameters, data?: TData, error?: Error) => void; }; /** * Request result interface */ export type UseRequestResult = { /** Response data */ data: TData | undefined; /** Loading state */ loading: boolean; /** Error object */ error: Error | undefined; /** Request parameters */ params: TParameters | undefined; /** Execute the request manually */ run: (...parameters: TParameters) => void; /** Execute the request with previous params */ runAsync: (...parameters: TParameters) => Promise; /** Refresh the request */ refresh: () => void; /** Refresh asynchronously */ refreshAsync: () => Promise; /** Cancel the current request */ cancel: () => void; /** Mute the current request (don't trigger state updates) */ mutate: (data: TData | ((oldData: TData | undefined) => TData)) => void; }; /** * Hook for advanced data fetching with caching, retries, and more * * @template TData - The return type of the request * @template TParams - The parameter types for the request * @param service - Request service function * @param options - Request options * @returns Request result object * * @example * ```tsx * const { data, loading, error, run } = useRequest( * (userId: string) => fetch(`/api/users/${userId}`).then(res => res.json()), * { * defaultParams: ['123'], * retry: { count: 3 }, * refreshOnWindowFocus: true, * } * ); * ``` */ export declare function useRequest(service: (...args: TParameters) => Promise, requestOptions?: UseRequestOptions): UseRequestResult; //# sourceMappingURL=useRequest.d.ts.map