Function fromEvent

  • Converts an event emitter event into an async-iterable stream.

    Type Parameters

    • TSource

      The type of elements in the emitter stream.

    Parameters

    • obj: EventedTarget

      The object that emits the events to turn into an async-iterable.

    • eventName: string

    Returns AsyncIterable<TSource>

    An async-iterable sequence created from the events emitted from the evented target.

  • Converts an event emitter event into an async-iterable stream.

    Type Parameters

    • TSource

      The type of elements in the emitter stream.

    Parameters

    • obj: EventedTarget

      The object that emits the events to turn into an async-iterable.

    • eventName: string
    • resultSelector: ((...args) => TSource)

      The result selector for the event.

        • (...args): TSource
        • Parameters

          • Rest ...args: any[]

          Returns TSource

    Returns AsyncIterable<TSource>

    An async-iterable sequence created from the events emitted from the evented target.

  • Converts an event emitter event into an async-iterable stream.

    Type Parameters

    • TSource

      The type of elements in the emitter stream.

    Parameters

    • obj: EventedTarget

      The object that emits the events to turn into an async-iterable.

    • eventName: string
    • options: EventListenerOptions

      The options for listening to the events such as capture, passive and once.

    Returns AsyncIterable<TSource>

    An async-iterable sequence created from the events emitted from the evented target.

  • Converts an event emitter event into an async-iterable stream.

    Type Parameters

    • TSource

      The type of elements in the emitter stream.

    Parameters

    • obj: EventedTarget

      The object that emits the events to turn into an async-iterable.

    • eventName: string
    • options: EventListenerOptions

      The options for listening to the events such as capture, passive and once.

    • resultSelector: ((...args) => TSource)

      The result selector for the event.

        • (...args): TSource
        • Parameters

          • Rest ...args: any[]

          Returns TSource

    Returns AsyncIterable<TSource>

    An async-iterable sequence created from the events emitted from the evented target.