• Await an event from an emitter and resume once the event is emitted. If the event results any results they are returned as result of the promise. When the event returns a single result it is returned as single item, when the event emits

    Type Parameters

    • A

    • E extends string | symbol = string

    Parameters

    • eventName: E

      Name of the event to listen to

    • emitter: {
          once(eventName, listener) => any;
      }

      Emitter emitting the event

      • once:function
        • Parameters

          • eventName: E
          • listener: ((arg) => any)
              • (arg): any
              • Parameters

                • arg: A

                Returns any

          Returns any

    • Optional timeout: number

      Optional timeout in ms, if no event is emitted within the timeout an exception os thrown. Defaults to indefinitely

    Returns Promise<A>

  • Await an event from an emitter and resume once the event is emitted. If the event results any results they are returned as result of the promise. When the event returns a single result it is returned as single item, when the event emits

    Type Parameters

    • A extends any[]

    • E extends string | symbol = string

    Parameters

    • eventName: E

      Name of the event to listen to

    • emitter: {
          once(eventName, listener) => any;
      }

      Emitter emitting the event

      • once:function
        • Parameters

          • eventName: E
          • listener: ((...arg) => any)
              • (...arg): any
              • Parameters

                • Rest ...arg: A

                Returns any

          Returns any

    • Optional timeout: number

      Optional timeout in ms, if no event is emitted within the timeout an exception os thrown. Defaults to indefinitely

    Returns Promise<A>