Class WaitForValue<T>

Queue of a single item, only once.

Allows for simple synchronisation.

const q = Flow.waitForValue();

// In some part of the code add a value
const value = q.add();

// Somewhere else, wait for value
await q.get(value);

It is not possible to add a second item, however it is possible to call get as many times as you need.

The .isUsed property allows you to to check if a value has been already added to the queue.

Based on: https://2ality.com/2024/05/proposal-promise-with-resolvers.html

Type Parameters

  • T

Constructors

Accessors

Methods

Constructors

Accessors

  • get isUsed(): boolean
  • Returns true if a value has been added and therefore no more values can be written

    Returns boolean

Methods

  • Parameters

    • value: T

    Returns void

  • Returns Promise<T>