/** * This file provides utilities for managing and processing load queues in a browser environment. * * It includes: * - A system for creating and managing load queues identified by unique symbols. * - A script store that holds callbacks associated with controllers. * - A React hook for using and managing controllers within a script store. * * Example usage: * * const MY_QUEUE_SYMBOL = Symbol.for('my-queue'); * const MY_STORE_SYMBOL = Symbol.for('my-controllers-store'); * * const myStore = getScriptStore(MY_STORE_SYMBOL); * * createLoadQueue({ * store: myStore, * createController: () => new MyController(), * queueKey: MY_QUEUE_SYMBOL, * }); * * const controller = useController(myStore); */ export type ControllerLoadedCallback = (controller: T) => void; export declare const QUEUES_SYMBOL: unique symbol; export declare const SINGLE_QUEUE_SYMBOL: unique symbol; export type ScriptStore = ControllerLoadedCallback[]; /** * Interface for creating a load queue. * * @template T - Type of the controller created in the queue. */ export interface CreateLoadQueueArgs { /** * The store where callbacks are saved. * * @type {ScriptStore} */ store: ScriptStore; /** * Function that creates a controller. * * @returns {T} A new controller instance. */ createController: () => T; /** * Flag to check if the queue is already created. * * @type {boolean} [isQueueCreated] */ isQueueCreated?: boolean; /** * Callback to handle queue creation. * * @param {boolean} created - Indicates if the queue was successfully created. */ onQueueCreated?: (created: boolean) => void; /** * Symbol key for identifying the queue. * * @type {symbol} [queueKey] */ queueKey?: symbol; } /** * Retrieves or initializes a script store for the given symbol key. * * @param {symbol} storeKey - The key associated with the script store. * @returns {ScriptStore} The script store associated with the given key. */ export declare const getScriptStore: (storeKey: symbol) => ScriptStore; /** * Retrieves the status of whether the queue associated with the queueKey is created. * * @param {symbol} queueKey - The key associated with the queue. * @returns {boolean} Whether the queue is created. */ export declare const getQueueStore: (queueKey: symbol) => boolean; /** * Creates and manages a load queue. * * @param {CreateLoadQueueArgs} args - The arguments required to create a load queue. * @returns {void} */ export declare const createLoadQueue: ({ store, createController, queueKey, isQueueCreated, onQueueCreated, }: CreateLoadQueueArgs) => void; declare global { interface Window { [key: symbol]: unknown; [QUEUES_SYMBOL]: Record; } }