A type-safe event emitter.

Type Parameters

  • E

    The interface that maps event names and event objects.

Hierarchy

  • Emitter

Constructors

Methods

Constructors

Methods

  • Type Parameters

    • EventName extends string | number | symbol

    Parameters

    • eventName: EventName
    • event: E[EventName]

    Returns void

  • Removes an event listener from the emitter.

    Type Parameters

    • EventName extends string | number | symbol

    Parameters

    • eventName: EventName

      The event name.

    • key: unknown

      The event handler to remove, or the key for removing the handler.

    Returns Emitter<E>

  • Adds an event listener to the emitter.

    Type Parameters

    • EventName extends string | number | symbol

    Parameters

    • eventName: EventName

      The event name to listen.

    • handler: Handler<E[EventName]>

      The event handler.

    • Optional opt_options: {
          key: unknown;
      }

      The options.

      • key: unknown

        The key that can be used for removing the handler.

    Returns Emitter<E>

Generated using TypeDoc