ixfx
    Preparing search index...

    Class SyncWait

    Simple synchronisation. Supports only a single signal/waiter. Expects one or more calls to .signal() for .forSignal() to resolve

    const sw = new SyncWait();
    obj.addEventListener(`click`, () => {
    sw.signal();
    });

    // Wait until click event
    await sw.forSignal();

    forSignal can also take a maximum time to wait. If the time elapses, an exception is thrown.

    didSignal returns true/false if signal happened rather than throwing an exception.

    Constructors

    Methods

    • An alternative to forSignal, returning true if signalled, or false if wait period was exceeded

      const s = await sw.didSignal(5000);
      

      Parameters

      • maximumWaitMs: number

      Returns Promise<boolean>

    • Throw away any previous signalled state. This will cause any currently waiters to throw

      Returns void

    • Call with await to wait until .signal() happens. If a wait period is specified, an exception is thrown if signal does not happen within this time.

      Parameters

      • OptionalmaximumWaitMs: number

      Returns Promise<void>

    • Returns void