import { Dispatcher, ExtractErrorType, CacheValueType, ExtractResponseType, RequestInstance, ExtractAdapterType, ExtractAdapterStatusType, ExtractAdapterExtraType, ExtractAdapterResolvedType, NullableType, CacheSetState, LoggerMethods } from '@hyper-fetch/core'; import { isEqual } from '../../utils'; export type UseTrackedStateProps = { request: T; logger: LoggerMethods; initialResponse: NullableType>>; dispatcher: Dispatcher>; dependencyTracking: boolean; deepCompare: boolean | typeof isEqual; keepPreviousData?: "auto" | "preserve" | "clean"; disabled?: boolean; revalidate?: boolean; }; export type UseTrackedStateReturn = [ UseTrackedStateType, UseTrackedStateActions, { setRenderKey: (renderKey: keyof UseTrackedStateType) => void; setCacheData: (cacheData: CacheValueType, ExtractErrorType>) => void; getStaleStatus: () => boolean; getIsDataProcessing: (cacheKey: string) => boolean; } ]; export type UseTrackedStateType = { /** * Request response data */ data: null | ExtractResponseType; /** * Request response error */ error: null | ExtractErrorType; /** * Request loading state */ loading: boolean; /** * Request status */ status: null | ExtractAdapterStatusType> | null; /** * Request additional response data */ extra: null | ExtractAdapterExtraType>; /** * Information whether request succeeded */ success: boolean; /** * Request attempts */ retries: number; /** * Request response timestamp */ responseTimestamp: null | Date; /** * Request response timestamp */ requestTimestamp: null | Date; }; export type UseTrackedStateActions = { /** * Action to set custom data. We can do it locally(inside hook state). * If you need to update cache data use client.cache.update(). method. */ setData: (data: CacheSetState | null>) => void; /** * Action to set custom error. We can do it locally(inside hook state). * If you need to update cache data use client.cache.update() method. */ setError: (error: CacheSetState | null>) => void; /** * Action to set custom loading. We can do it locally(inside hook state). * If you need to update cache data use client.cache.update() method. */ setLoading: (loading: CacheSetState) => void; /** * Action to set custom status. We can do it locally(inside hook state). * If you need to turn on loading for all listening hooks use client.requestManager.events.emitLoading() method. */ setStatus: (status: CacheSetState>>) => void; /** * Action to set custom success. We can do it locally(inside hook state). * If you need to update cache data use client.cache.update() method. */ setSuccess: (success: CacheSetState) => void; /** * Action to set custom additional data. We can do it locally(inside hook state). * If you need to update cache data use client.cache.update() method. */ setExtra: (extra: CacheSetState> | null>) => void; /** * Action to set custom retries count. We can do it locally(inside hook state). * If you need to update cache data use client.cache.update() method. */ setRetries: (retries: CacheSetState) => void; /** * Action to set custom timestamp. We can do it locally(inside hook state). * If you need to update cache data use client.cache.update() method. */ setResponseTimestamp: (timestamp: CacheSetState) => void; /** * Action to set custom timestamp. We can do it locally(inside hook state). * If you need to update cache data use client.cache.update() method. */ setRequestTimestamp: (timestamp: CacheSetState) => void; /** * Reset all state fields to their initial values (data, error, status, extra → null, loading → false, etc.). */ clearState: () => void; }; //# sourceMappingURL=use-tracked-state.types.d.ts.map