ixfx
    Preparing search index...

    Class TaskQueueMutable

    Simple task queue. Each task is awaited and run in turn.

    The TaskQueueMutable is shared across your code, so you don't create it directly. Rather, use:

    import { TaskQueueMutable } from "https://unpkg.com/ixfx/dist/flow.js"
    const queue = TaskQueueMutable.shared;
    import { TaskQueueMutable, sleep } from "https://unpkg.com/ixfx/dist/flow.js"
    const queue = TaskQueueMutable.shared;
    q.enqueue(async () => {
    // Takes one second to run
    await sleep(1000);
    });

    You can listen to events from the TaskQueue:

    TaskQueueMutable.shared.addEventListener(`started`, () => {
    // Queue was empty, now started processing
    });

    TaskQueueMutable.shared.addEventListener(`empty`, () => {
    // Queue has finished processing all items
    });

    Hierarchy (View Summary)

    Properties

    shared: TaskQueueMutable = ...

    Accessors

    • get isDisposed(): boolean

      Returns boolean

    • get isEmpty(): boolean

      Returns true if queue is empty

      Returns boolean

    • get length(): number

      Number of items in queue

      Returns number

    Methods

    • Clears all tasks, and stops any scheduled processing. Currently running tasks will continue.

      Returns void

    • Adds a task. This triggers processing loop if not already started.

      queue.add(async () => {
      await sleep(1000);
      });

      Parameters

      • task: () => Promise<void>

        Task to run

      Returns number