@equinor/fusion-query
Version:
Reactive data fetching and caching library with observable streams and comprehensive event system
26 lines (25 loc) • 1.3 kB
TypeScript
import type { Flow } from '@equinor/fusion-observable';
import { type Actions } from './actions';
import type { QueryClientState, QueryFn, RetryOptions } from './types';
/**
* Handles incoming request actions by transforming them into execute actions.
*
* @param action$ - The stream of actions being dispatched in the system.
* @returns An Observable that emits execute actions for each request action.
*/
export declare const handleRequests: Flow<Actions, QueryClientState>;
/**
* Handles the execution of a query.
*
* @param fetch - The function used to execute the query.
* @returns A flow that handles the execution of the query.
*/
export declare const handleExecution: <TType, TArgs>(fetch: QueryFn<TType, TArgs>) => Flow<Actions, QueryClientState<TArgs>>;
/**
* Handles execution failure by scheduling retries according to the provided retry options.
* If the maximum number of retries is exceeded or no retry options are provided, it emits an error action.
* Otherwise, it schedules a retry after a delay determined by the retry options.
*
* @param config - Optional configuration for retry behavior, including the maximum number of retries and delay between retries.
*/
export declare const handleFailure: (config?: Partial<RetryOptions>) => Flow<Actions, QueryClientState>;