import type { SubscriptionAction } from './subscription-actions'; export interface QueuedItem { action: SubscriptionAction; args?: { force?: boolean; [p: string]: any; }; } /** * Queue (FIFO) of pending subscription actions. Allows for easier abstraction of managing list of pending actions. * In addition to standard queue implementation, provides: * - merging consecutive duplicated actions * - merging of uneccessary combinations: ACTION_SUBSCRIBE action before ACTION_UNSUBSCRIBE, is merged to ACTION_UNSUBSCRIBE. */ declare class SubscriptionQueue { items: QueuedItem[]; private getLastItem; /** * Add pending action to a queue and making sure that we remove unecessary actions like: * - duplicates. * - ACTION_SUBSCRIBE action before ACTION_UNSUBSCRIBE. * * @param queuedItem - action with arguments to add to the queue. */ enqueue(queuedItem: QueuedItem): void; /** * This is called at the point of subscribing or on a subscribe error. * We know at that point we do not need any follow up modifys * or subscribes. */ clearModifys(): boolean; /** * Returns the action from the beginning of a queue without removing it. * @returns Next action. */ peekAction(): SubscriptionAction | undefined; /** * Peeks the next action */ peek(): QueuedItem | undefined; /** * Looks to see if the end state after processing actions is to be unsubscribed or not * If the actions are indeterminate (for example, no actions) then it returns the current * state passed as a argument */ peekIsSubscribed(isSubscribedNow: boolean): boolean; /** * Removes and returns the action from the beginning of a queue. * @returns First action, if queue is not empty. Otherwise undefined. */ dequeue(): QueuedItem | undefined; /** * Resets queue. */ reset(): void; /** * @returns True if empty. */ isEmpty(): boolean; } export default SubscriptionQueue;