A utility class that waits until a specified condition is met or a timeout occurs, and then executes a single action.

const waiter = new AcEdConditionWaiter(
() => isDataReady(), // condition
() => console.log('Ready or timed out'), // action
1000, // check every 1s
10000 // timeout after 10s
);

waiter.start();

Constructors

Methods

Constructors

  • Creates a new AcEdConditionWaiter.

    Parameters

    • condition: () => boolean

      The condition function to check periodically.

    • action: () => void

      The action to execute once when the condition is met or timeout occurs.

    • checkInterval: number = 1000

      How often (ms) to check the condition. Default: 1000 ms.

    • timeout: number = 0

      Maximum time (ms) to wait before executing the action. Default: 0 (no timeout).

    Returns AcEdConditionWaiter

Methods

  • Starts checking the condition at the defined interval. Executes the action once when the condition becomes true or when timeout is reached.

    Returns void