UNPKG

easy-action-queue

Version:

A lightweight library to queue and manage actions with configurable concurrency, supporting synchronous, asynchronous, and observable actions.

27 lines 1.02 kB
import { Observable } from "rxjs"; export default class EasyActionQueue { concurrency: number; private readonly queue; private readonly runningActions; private readonly idleSub; private paused; constructor(concurrency?: number); get idleObs(): Observable<boolean>; getQueueSize(): number; updateConcurrency(newConcurrency: number): void; pause(): void; resume(): void; /** * T is type for final value, R is type of return value from the callback * action callback will be enqueued and when it gets triggered, the promise will resolve with the result * if the callback returns a string, it will be resolved in promise * if it is async operation, the result will be resolved in promise */ enqueue<T, R>(action: () => T | Promise<T> | Observable<T>): Promise<T>; clearQueue(): void; private processQueue; private handleResponse; private handleRejection; private handleCompletion; } //# sourceMappingURL=ActionQueue.d.ts.map