@hyper-fetch/react
Version:
React hooks and utils for the hyper-fetch
740 lines (706 loc) • 28.5 kB
TypeScript
import { RequestInstance, RequestResponseEventType, ResponseSuccessType, ExtractResponseType, ExtractAdapterType, ResponseErrorType, ExtractErrorType, ResponseType, RequestEventType, RequestProgressEventType, Dispatcher, LoggerMethods, CacheValueType, ExtractAdapterStatusType, ExtractAdapterExtraType, CacheSetState, NullableType, ExtractAdapterResolvedType, ResponseDetailsType, ExtendRequest, ExtractPayloadType, EmptyTypes, ExtractParamsType, ExtractQueryParamsType, RequiredKeys, RequestSendType, QueueItemType, ProgressType, ClientInstance } from '@hyper-fetch/core';
import { SocketInstance, ExtractSocketExtraType, ListenerInstance, ExtractListenerResponseType, EmitterInstance, EmitterCallbackErrorType, EmitType } from '@hyper-fetch/sockets';
import * as react_jsx_runtime from 'react/jsx-runtime';
import React from 'react';
/**
* This hooks aims to retrieve data from server.
* @param request Request instance
* @param options Hook options
* @returns
*/
declare const useFetch: <R extends RequestInstance>(request: UseFetchRequest<R>, options?: UseFetchOptionsType<R>) => UseFetchReturnType<R>;
/**
* This is helper hook that handles main Hyper-Fetch event/data flow
* @internal
* @param options
* @returns
*/
declare const useRequestEvents: <R extends RequestInstance>({ request, dispatcher, logger, actions, setCacheData, getIsDataProcessing, }: UseRequestEventsPropsType<R>) => UseRequestEventsReturnType<R>;
type UseRequestEventsDataMap = {
unmount: VoidFunction;
};
type UseRequestEventsLifecycleMap = Map<string, {
unmount: VoidFunction;
}>;
type UseRequestEventsPropsType<T extends RequestInstance> = {
request: T;
dispatcher: Dispatcher<ExtractAdapterType<T>>;
logger: LoggerMethods;
actions: UseTrackedStateActions<T>;
setCacheData: (cacheData: CacheValueType<ExtractResponseType<T>, ExtractErrorType<T>>) => void;
getIsDataProcessing: (cacheKey: string) => boolean;
};
type UseRequestEventsActionsType<T extends RequestInstance> = {
/**
* Callback that allows canceling ongoing requests from the given queryKey.
*/
abort: () => void;
/**
* Helper hook listening on success response.
*/
onSuccess: (callback: OnSuccessCallbackType<T>) => void;
/**
* Helper hook listening on error response.
*/
onError: (callback: OnErrorCallbackType<T>) => void;
/**
* Helper hook listening on aborting of requests. Abort events are not triggering onError callbacks.
*/
onAbort: (callback: OnErrorCallbackType<T>) => void;
/**
* Helper hook listening on request going into offline awaiting for network connection to be restored. It will not trigger onError when 'offline' mode is set on request.
*/
onOfflineError: (callback: OnErrorCallbackType<T>) => void;
/**
* Helper hook listening on any response.
*/
onFinished: (callback: OnFinishedCallbackType<T>) => void;
/**
* Helper hook listening on request start.
*/
onRequestStart: (callback: OnStartCallbackType<T>) => void;
/**
* Helper hook listening on response start(before we receive all data from server).
*/
onResponseStart: (callback: OnStartCallbackType<T>) => void;
/**
* Helper hook listening on download progress ETA. We can later match given requests by their id's or request instance which holds all data which is being transferred.
*/
onDownloadProgress: (callback: OnProgressCallbackType) => void;
/**
* Helper hook listening on upload progress ETA. We can later match given requests by their id's or request instance which holds all data which is being transferred.
*/
onUploadProgress: (callback: OnProgressCallbackType) => void;
};
type UseRequestEventsReturnType<T extends RequestInstance> = [
UseRequestEventsActionsType<T>,
{
addCacheDataListener: (request: T) => VoidFunction;
clearCacheDataListener: VoidFunction;
addLifecycleListeners: (request: T, requestId?: string) => VoidFunction;
removeLifecycleListener: (requestId: string) => void;
clearLifecycleListeners: () => void;
}
];
type CallbackParameters<Request extends RequestInstance, ResponseType> = {
response: ResponseType;
} & Omit<RequestResponseEventType<Request>, "response">;
type OnSuccessCallbackType<Request extends RequestInstance> = (params: CallbackParameters<Request, ResponseSuccessType<ExtractResponseType<Request>, ExtractAdapterType<Request>>>) => void | Promise<void>;
type OnErrorCallbackType<Request extends RequestInstance> = (params: CallbackParameters<Request, ResponseErrorType<ExtractErrorType<Request>, ExtractAdapterType<Request>>>) => void | Promise<void>;
type OnFinishedCallbackType<Request extends RequestInstance> = (params: CallbackParameters<Request, ResponseType<ExtractResponseType<Request>, ExtractErrorType<Request>, ExtractAdapterType<Request>>>) => void | Promise<void>;
type OnStartCallbackType<Request extends RequestInstance> = (data: RequestEventType<Request>) => void | Promise<void>;
type OnProgressCallbackType = <Request extends RequestInstance>(data: RequestProgressEventType<Request>) => void | Promise<void>;
/**
* Check if value is empty
* @param value any object or primitive
* @returns true when value is empty
*/
declare const isEmpty: (value: unknown) => boolean;
/**
* Allow to deep compare any passed values
* @param firstValue unknown
* @param secondValue unknown
* @returns true when elements are equal
*/
declare const isEqual: (firstValue: unknown, secondValue: unknown) => boolean;
declare const getBounceData: (bounceData: {
reset: () => void;
active: boolean;
}) => {
reset: () => void;
active: boolean;
};
type UseTrackedStateProps<T extends RequestInstance> = {
request: T;
logger: LoggerMethods;
initialResponse: NullableType<Partial<ExtractAdapterResolvedType<T>>>;
dispatcher: Dispatcher<ExtractAdapterType<T>>;
dependencyTracking: boolean;
deepCompare: boolean | typeof isEqual;
disabled?: boolean;
revalidate?: boolean;
};
type UseTrackedStateReturn<T extends RequestInstance> = [
UseTrackedStateType<T>,
UseTrackedStateActions<T>,
{
setRenderKey: (renderKey: keyof UseTrackedStateType<T>) => void;
setCacheData: (cacheData: CacheValueType<ExtractResponseType<T>, ExtractErrorType<T>>) => void;
getStaleStatus: () => boolean;
getIsDataProcessing: (cacheKey: string) => boolean;
}
];
type UseTrackedStateType<T extends RequestInstance = RequestInstance> = {
/**
* Request response data
*/
data: null | ExtractResponseType<T>;
/**
* Request response error
*/
error: null | ExtractErrorType<T>;
/**
* Request loading state
*/
loading: boolean;
/**
* Request status
*/
status: null | ExtractAdapterStatusType<ExtractAdapterType<T>> | null;
/**
* Request additional response data
*/
extra: null | ExtractAdapterExtraType<ExtractAdapterType<T>>;
/**
* Information whether request succeeded
*/
success: boolean;
/**
* Request attempts
*/
retries: number;
/**
* Request response timestamp
*/
responseTimestamp: null | Date;
/**
* Request response timestamp
*/
requestTimestamp: null | Date;
};
type UseTrackedStateActions<T extends RequestInstance> = {
/**
* 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<ExtractResponseType<T> | 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<ExtractErrorType<T> | 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<boolean>) => 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<ExtractAdapterStatusType<ExtractAdapterType<T>>>) => 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<boolean>) => 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<ExtractAdapterExtraType<ExtractAdapterType<T>> | 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<number>) => 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<Date>) => 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<Date>) => void;
};
declare const initialState: UseTrackedStateType;
/**
*
* @param request
* @param initialResponse
* @param dispatcher
* @param dependencies
* @internal
*/
declare const useTrackedState: <T extends RequestInstance>({ request, dispatcher, initialResponse, deepCompare, dependencyTracking, disabled, revalidate, }: UseTrackedStateProps<T>) => UseTrackedStateReturn<T>;
declare const getDetailsState: (state?: UseTrackedStateType<RequestInstance>, details?: Partial<ResponseDetailsType>) => ResponseDetailsType;
declare const isStaleCacheData: (staleTime: number, staleTimestamp: NullableType<Date | number>) => boolean;
declare const getValidCacheData: <T extends RequestInstance>(request: T, initialResponse: NullableType<Partial<ExtractAdapterResolvedType<T>>>, cacheData: NullableType<CacheValueType<ExtractResponseType<T>, ExtractErrorType<T>, ExtractAdapterType<T>>>) => CacheValueType<ExtractResponseType<T>, ExtractErrorType<T>, ExtractAdapterType<T>> | null;
declare const getTimestamp: (timestamp?: NullableType<number | Date>) => Date | null;
declare const getIsInitiallyLoading: <T extends RequestInstance>({ queryKey, dispatcher, hasState, revalidate, disabled, }: {
queryKey: string;
dispatcher: Dispatcher<ExtractAdapterType<T>>;
hasState: boolean;
revalidate?: boolean;
disabled?: boolean;
}) => boolean;
declare const getInitialState: <T extends RequestInstance>({ initialResponse, dispatcher, request, disabled, revalidate, }: {
initialResponse: NullableType<Partial<ExtractAdapterResolvedType<T>>>;
dispatcher: Dispatcher<ExtractAdapterType<T>>;
request: T;
disabled?: boolean;
revalidate?: boolean;
}) => UseTrackedStateType<T>;
declare const useSocketState: <DataType, Socket extends SocketInstance>(socket: Socket, { dependencyTracking }: UseSocketStateProps) => readonly [UseSocketStateType<Socket, DataType>, {
setData: (data: DataType | null) => void;
setExtra: (extra: ExtractSocketExtraType<Socket> | null) => void;
setConnected: (connected: boolean) => void;
setConnecting: (connecting: boolean) => void;
setTimestamp: (timestamp: number | null) => void;
}, {
onConnected: (callback: VoidFunction) => void;
onDisconnected: (callback: VoidFunction) => void;
onError: <ErrorType = Event>(callback: (event: ErrorType) => void) => void;
onConnecting: (callback: VoidFunction) => void;
onReconnecting: (callback: (data: {
attempts: number;
}) => void) => void;
onReconnectingFailed: (callback: (data: {
attempts: number;
}) => void) => void;
}, {
readonly setRenderKey: (renderKey: keyof UseSocketStateType<Socket, DataType>) => void;
}];
type UseSocketStateType<Socket extends SocketInstance, DataType = any> = {
data: DataType | null;
extra: ExtractSocketExtraType<Socket> | null;
connected: boolean;
connecting: boolean;
timestamp: number | null;
};
type UseSocketStateProps = {
dependencyTracking?: boolean;
};
declare const initialSocketState: UseSocketStateType<SocketInstance>;
type UseFetchCastRequest<R extends RequestInstance> = ExtendRequest<R, {
hasData: ExtractPayloadType<R> extends EmptyTypes ? boolean : true;
hasParams: ExtractParamsType<R> extends EmptyTypes ? boolean : true;
hasQuery: ExtractQueryParamsType<R> extends EmptyTypes ? boolean : true;
}>;
type UseFetchRequest<R extends RequestInstance> = R extends UseFetchCastRequest<R> ? R : UseFetchCastRequest<R>;
type UseFetchOptionsType<R extends RequestInstance> = {
/**
* Refetch dependencies
*/
dependencies?: any[];
/**
* Disable fetching
*/
disabled?: boolean;
/**
* If `true` it will rerender only when values used by our component gets changed. Otherwise it will rerender on any change.
*/
dependencyTracking?: boolean;
/**
* If `true` it will refetch data in background no matter if we have it from cache.
*/
revalidate?: boolean;
/**
* If cache is empty we can use placeholder data.
*/
initialResponse?: NullableType<Partial<ExtractAdapterResolvedType<R>>>;
/**
* Enable/disable refresh data
*/
refresh?: boolean;
/**
* Refresh data interval time
*/
refreshTime?: number;
/**
* Enable/disable data refresh if our tab is not focused(used by user at given time).
*/
refetchBlurred?: boolean;
/**
* Enable/disable data refresh if user leaves current tab.
*/
refetchOnBlur?: boolean;
/**
* Enable/disable data refresh if user enters current tab.
*/
refetchOnFocus?: boolean;
/**
* Enable/disable data refresh if network is restored.
*/
refetchOnReconnect?: boolean;
/**
* Enable/disable debouncing for often changing keys or refreshing, to limit requests to server.
*/
bounce?: boolean;
/**
* Deep comparison function for hook to check for equality in incoming data, to limit rerenders.
*/
deepCompare?: boolean | typeof isEqual;
} & ({
/**
* Possibility to choose between debounce and throttle approaches
*/
bounceType?: "debounce";
/**
* How long it should bounce requests.
*/
bounceTime?: number;
/**
* Not applicable for debounce mode
*/
bounceTimeout?: void;
} | {
/**
* Possibility to choose between debounce and throttle approaches
*/
bounceType: "throttle";
/**
* How long it should bounce requests.
*/
bounceTime?: number;
/**
* ONLY in throttle mode - options for handling last bounce event
*/
bounceTimeout?: number;
});
type UseFetchReturnType<R extends RequestInstance> = UseTrackedStateType<R> & UseTrackedStateActions<R> & UseRequestEventsActionsType<R> & {
/**
* Data related to current state of the bounce usage
*/
bounce: {
/**
* Active state of the bounce method
*/
active: boolean;
/**
* Method to stop the active bounce method execution
*/
reset: () => void;
};
/**
* Refetch current request
*/
refetch: () => void;
};
declare const getRefreshTime: (refreshTime: number, dataTimestamp?: Date) => number;
type DefaultOptionsType$1 = RequiredKeys<Omit<UseFetchOptionsType<RequestInstance>, "initialResponse">> & {
initialResponse: null;
};
declare const useFetchDefaultOptions: DefaultOptionsType$1;
/**
* This hooks aims to mutate data on the server.
* @param request
* @param options
* @returns
*/
declare const useSubmit: <RequestType extends RequestInstance>(request: RequestType, options?: UseSubmitOptionsType<RequestType>) => UseSubmitReturnType<RequestType>;
type UseSubmitOptionsType<T extends RequestInstance> = {
/**
* Disable submitting
*/
disabled?: boolean;
/**
* If cache is empty we can use placeholder data.
*/
initialResponse?: NullableType<Partial<ExtractAdapterResolvedType<T>>>;
/**
* Enable/disable debouncing for often changing keys or refreshing, to limit requests to server.
*/
bounce?: boolean;
/**
* If `true` it will rerender only when values used by our component gets changed. Otherwise it will rerender on any change.
*/
dependencyTracking?: boolean;
/**
* Deep comparison function for hook to check for equality in incoming data, to limit rerenders.
*/
deepCompare?: boolean | typeof isEqual;
} & ({
/**
* Possibility to choose between debounce and throttle approaches
*/
bounceType?: "debounce";
/**
* How long it should bounce requests.
*/
bounceTime?: number;
} | {
/**
* Possibility to choose between debounce and throttle approaches
*/
bounceType: "throttle";
/**
* How long it should interval requests.
*/
bounceTime?: number;
/**
* ONLY in throttle mode - options for handling last bounce event
*/
bounceTimeout?: number;
});
type UseSubmitReturnType<RequestType extends RequestInstance> = Omit<UseTrackedStateType<RequestType>, "loading"> & UseTrackedStateActions<RequestType> & {
/**
* Callback which allows to cancel ongoing requests from given queryKey.
*/
abort: () => void;
/**
* Helper hook listening on success response.
*/
onSubmitSuccess: (callback: OnSuccessCallbackType<RequestType>) => void;
/**
* Helper hook listening on error response.
*/
onSubmitError: (callback: OnErrorCallbackType<RequestType>) => void;
/**
* Helper hook listening on any response.
*/
onSubmitFinished: (callback: OnFinishedCallbackType<RequestType>) => void;
/**
* Helper hook listening on request start.
*/
onSubmitRequestStart: (callback: OnStartCallbackType<RequestType>) => void;
/**
* Helper hook listening on response start(before we receive all data from server).
*/
onSubmitResponseStart: (callback: OnStartCallbackType<RequestType>) => void;
/**
* Helper hook listening on download progress ETA. We can later match given requests by their id's or request instance which holds all data which is being transferred.
*/
onSubmitDownloadProgress: (callback: OnProgressCallbackType) => void;
/**
* Helper hook listening on upload progress ETA. We can later match given requests by their id's or request instance which holds all data which is being transferred.
*/
onSubmitUploadProgress: (callback: OnProgressCallbackType) => void;
/**
* Helper hook listening on aborting of requests. Abort events are not triggering onError callbacks.
*/
onSubmitAbort: (callback: OnErrorCallbackType<RequestType>) => void;
/**
* Helper hook listening on request going into offline awaiting for network connection to be restored. It will not trigger onError when 'offline' mode is set on request.
*/
onSubmitOfflineError: (callback: OnErrorCallbackType<RequestType>) => void;
/**
* Method responsible for triggering requests. It return Promise which will be resolved with the request.
*/
submit: RequestSendType<RequestType>;
/**
* Request loading state
*/
submitting: boolean;
/**
* Data related to current state of the bounce usage
*/
bounce: {
/**
* Active state of the bounce method
*/
active: boolean;
/**
* Method to stop the active bounce method execution
*/
reset: () => void;
};
/**
* Refetch current request
*/
refetch: () => void;
};
type DefaultOptionsType = RequiredKeys<Omit<UseSubmitOptionsType<RequestInstance>, "initialResponse">> & {
initialResponse: null;
};
declare const useSubmitDefaultOptions: DefaultOptionsType;
/**
* This hook allows to control dispatchers request queues
* @param request
* @param options
* @returns
*/
declare const useQueue: <Request extends RequestInstance>(request: Request, options?: UseQueueOptionsType) => UseQueueReturnType<Request>;
type UseQueueOptionsType = {
dispatcherType?: "auto" | "fetch" | "submit";
keepFinishedRequests?: boolean;
};
type QueueRequest<Request extends RequestInstance> = QueueItemType<Request> & {
failed?: boolean;
canceled?: boolean;
removed?: boolean;
success?: boolean;
/**
* Uploading progress for given request
*/
uploading: ProgressType;
/**
* Downloading progress for given request
*/
downloading: ProgressType;
/**
* Callback which allow to start previously stopped request.
*/
startRequest: () => void;
/**
* Callback which allow to stop request and cancel it if it's ongoing.
*/
stopRequest: () => void;
/**
* Removes request from the queue
*/
deleteRequest: () => void;
};
type UseQueueReturnType<T extends RequestInstance> = {
/**
* Queue status for provided request
*/
stopped: boolean;
/**
* List of requests for provided request
*/
requests: QueueRequest<T>[];
/**
* Request dispatcher instance
*/
dispatcher: Dispatcher<ExtractAdapterType<T>>;
/**
* Callback which allow to stop queue, it will cancel ongoing requests.
*/
stop: () => void;
/**
* Callback which allow to pause queue. It will allow ongoing requests to be finished, but will stop next from being send.
*/
pause: () => void;
/**
* Callback which allow to start queue.
*/
start: () => void;
};
declare const useQueueDefaultOptions: RequiredKeys<UseQueueOptionsType>;
declare const useCache: <T extends RequestInstance>(request: T, options?: UseCacheOptionsType<T>) => UseCacheReturnType<T>;
declare const useCacheDefaultOptions: {
dependencyTracking: boolean;
initialResponse: null;
deepCompare: boolean;
};
type UseCacheOptionsType<T extends RequestInstance> = {
/**
* If `true` it will rerender only when values used by our component gets changed. Otherwise it will rerender on any change.
*/
dependencyTracking?: boolean;
/**
* If cache is empty we can use placeholder data.
*/
initialResponse?: CacheValueType<ExtractResponseType<T>, ExtractErrorType<T>>["data"] | null;
/**
* Deep comparison function for hook to check for equality in incoming data, to limit rerenders.
*/
deepCompare?: boolean | typeof isEqual;
};
type UseCacheReturnType<T extends RequestInstance> = UseTrackedStateType<T> & UseTrackedStateActions<T> & {
/**
* Invalidate cache for the current request or pass custom key to trigger it by invalidationKey(Regex / cacheKey).
*/
invalidate: (cacheKeys?: string | RegExp | RequestInstance | Array<string | RegExp | RequestInstance>) => void;
};
declare const useListener: <ListenerType extends ListenerInstance>(listener: ListenerType, options?: UseListenerOptionsType) => {
listen: () => void;
onEvent: (callback: NonNullable<((response: {
data: ExtractListenerResponseType<ListenerType>;
extra: Record<string, any>;
}) => void) | null>) => void;
onConnected: (callback: VoidFunction) => void;
onDisconnected: (callback: VoidFunction) => void;
onError: <ErrorType = Event>(callback: (event: ErrorType) => void) => void;
onConnecting: (callback: VoidFunction) => void;
onReconnecting: (callback: (data: {
attempts: number;
}) => void) => void;
onReconnectingFailed: (callback: (data: {
attempts: number;
}) => void) => void;
setData: (data: unknown) => void;
setExtra: (extra: any) => void;
setConnected: (connected: boolean) => void;
setConnecting: (connecting: boolean) => void;
setTimestamp: (timestamp: number | null) => void;
data: unknown;
extra: any;
connected: boolean;
connecting: boolean;
timestamp: number | null;
};
type UseListenerOptionsType = {
dependencyTracking?: boolean;
};
declare const useEmitter: <EmitterType extends EmitterInstance>(emitter: EmitterType, options?: UseEmitterOptionsType) => {
onEmit: (callback: (emitter: EmitterType) => void) => void;
onEmitError: (callback: EmitterCallbackErrorType) => void;
emit: EmitType<EmitterType>;
onConnected: (callback: VoidFunction) => void;
onDisconnected: (callback: VoidFunction) => void;
onError: <ErrorType = Event>(callback: (event: ErrorType) => void) => void;
onConnecting: (callback: VoidFunction) => void;
onReconnecting: (callback: (data: {
attempts: number;
}) => void) => void;
onReconnectingFailed: (callback: (data: {
attempts: number;
}) => void) => void;
setData: (data: unknown) => void;
setExtra: (extra: any) => void;
setConnected: (connected: boolean) => void;
setConnecting: (connecting: boolean) => void;
setTimestamp: (timestamp: number | null) => void;
connected: boolean;
connecting: boolean;
};
type UseEmitterOptionsType = {
dependencyTracking?: boolean;
};
declare const useAppManager: <Client extends ClientInstance>(client: Client) => UseAppManagerReturnType;
type UseAppManagerReturnType = {
/**
* Is window focused
*/
isFocused: boolean;
/**
* Network online status
*/
isOnline: boolean;
/**
* Network state setter
*/
setOnline: (isOnline: boolean) => void;
/**
* Focus state setter
*/
setFocused: (isFocused: boolean) => void;
};
type ProviderOptionsType = {
useFetchConfig?: Partial<UseFetchOptionsType<RequestInstance>>;
useSubmitConfig?: Partial<UseSubmitOptionsType<RequestInstance>>;
useCacheConfig?: Partial<UseCacheOptionsType<RequestInstance>>;
useQueueConfig?: Partial<UseQueueOptionsType>;
useListener?: Partial<UseListenerOptionsType>;
useEmitter?: Partial<UseEmitterOptionsType>;
};
type ProviderProps = {
/**
* Children to render
*/
children: React.ReactNode;
/**
* Configuration to set for available hooks
*/
config?: ProviderOptionsType;
};
type ProviderValueType = {
config: ProviderOptionsType;
setConfig: (newConfig: ProviderOptionsType) => void;
};
/**
* Context provider with configuration for hooks
* @param options
* @returns
*/
declare const Provider: ({ children, config }: ProviderProps) => react_jsx_runtime.JSX.Element;
/**
* Hook to allow reading current context config
* @returns
*/
declare const useProvider: () => ProviderValueType;
export { type CallbackParameters, type OnErrorCallbackType, type OnFinishedCallbackType, type OnProgressCallbackType, type OnStartCallbackType, type OnSuccessCallbackType, Provider, type ProviderOptionsType, type ProviderProps, type ProviderValueType, type QueueRequest, type UseAppManagerReturnType, type UseCacheOptionsType, type UseCacheReturnType, type UseEmitterOptionsType, type UseFetchCastRequest, type UseFetchOptionsType, type UseFetchRequest, type UseFetchReturnType, type UseListenerOptionsType, type UseQueueOptionsType, type UseQueueReturnType, type UseRequestEventsActionsType, type UseRequestEventsDataMap, type UseRequestEventsLifecycleMap, type UseRequestEventsPropsType, type UseRequestEventsReturnType, type UseSocketStateProps, type UseSocketStateType, type UseSubmitOptionsType, type UseSubmitReturnType, type UseTrackedStateActions, type UseTrackedStateProps, type UseTrackedStateReturn, type UseTrackedStateType, getBounceData, getDetailsState, getInitialState, getIsInitiallyLoading, getRefreshTime, getTimestamp, getValidCacheData, initialSocketState, initialState, isEmpty, isEqual, isStaleCacheData, useAppManager, useCache, useCacheDefaultOptions, useEmitter, useFetch, useFetchDefaultOptions, useListener, useProvider, useQueue, useQueueDefaultOptions, useRequestEvents, useSocketState, useSubmit, useSubmitDefaultOptions, useTrackedState };