Function once

  • Parameters

    • object: IEventLike

      Event object

    • event: string

      event name

    Returns Promise<unknown>

    Description

    Wait event once asynchronous

    Example

      import { events } from '@biorate/tools';

    (async () => {
    const object = new EventEmitter();
    const promise = events.once(object, 'test');
    object.emit('test', 1, 2, 3);
    const data = await promise;
    console.log(data); [1, 2, 3]
    })();

Generated using TypeDoc