import { Dispatch } from 'react'; /** * The type used to store workers in the state. */ export declare type Worker = { [identifier: string]: Record; } | (Record | undefined); /** * The state is composed of: * - a cache, which is a simple object with strings as keys and typed values; * - the workers currently loading elements. */ export interface State { cache: { [identifier: string]: V | undefined; }; worker: W; } /** * Type of actions which can be applied to the state. */ export declare const enum ActionType { AddElement = 0, StartWorking = 1, StopWorking = 2 } /** * The action used to add an element. */ interface AddElementAction { type: ActionType.AddElement; payload: { identifier: string; element: V | undefined; }; } /** * Create an action used to add an element. * * @param (unnamed) - The element to add. * @param (unnamed).identifier - The element identifier. * @param (unnamed).element - The element to add. * @returns The appropriate action. */ export declare function addElement({ identifier, element, }: { identifier: string; element: V | undefined; }): AddElementAction; /** * The action used to start working. */ interface StartWorkingAction { type: ActionType.StartWorking; payload: { identifier: string; worker: Record; }; } /** * Create an action used to start working. * * @param identifier - The element identifier. * @param worker - Any object, used to uniquely identify the worker. * @returns The appropriate action. */ export declare function startWorking(identifier: string, worker: Record): StartWorkingAction; /** * The action used to stop working. */ interface StopWorkingAction { type: ActionType.StopWorking; payload: { identifier: string; worker: Record; }; } /** * Create an action used to stop working. * * @param identifier - The element identifier. * @param worker - The object used to uniquely identify the worker. * @returns The appropriate action. */ export declare function stopWorking(identifier: string, worker: Record): StopWorkingAction; /** * The action expected by the reducer. */ export declare type Action = AddElementAction | StartWorkingAction | StopWorkingAction; /** * Alias for the useReducer return type. */ declare type ReducerSystem = [State, Dispatch>]; export default ReducerSystem;