Class EventEmitter<TEvents>

Type Parameters

Hierarchy

  • EventEmitter

Constructors

Properties

listeners: TEvents = ...

The Listeners that always run.

listenersOnce: TEvents = ...

The Listeners that only runs once.

instance?: any

The singleton.

Methods

  • Fire the event.

    Type Parameters

    Type Parameters

    • P extends string | number | symbol

    Parameters

    • event: P

      The event name.

    • Rest ...args: Parameters<TEvents[P][number]>

      The arguments to pass to the listeners.

    Returns Promise<EventEmitter<TEvents>>

  • Determine whether listeners exist.

    Type Parameters

    Type Parameters

    • P extends string | number | symbol

    Parameters

    • Optional event: P

      only check for listeners for the given event

    • Optional listener: Listener<Parameters<TEvents[P][number]>[number]>

      only check for listeners that match this given listener

    Returns boolean

  • Get the number of listeners registered.

    Parameters

    • Optional event: keyof TEvents

      only count the listeners for the given event

    Returns number

  • Remove the listeners.

    Type Parameters

    Type Parameters

    • P extends string | number | symbol

    Parameters

    • Optional event: P

      only remove listeners for the given event

    • Optional listener: TEvents[P][number]

      only remove the event listener that match the given listener.

    Returns EventEmitter<TEvents>

  • Bind the event listener that should only run once.

    Type Parameters

    Type Parameters

    • P extends string | number | symbol

    Parameters

    • event: P
    • listener: Listener<Parameters<TEvents[P][number]>[number]>

    Returns EventEmitter<TEvents>

  • Bind the event and to the front of the stack.

    Type Parameters

    Type Parameters

    • P extends string | number | symbol

    Parameters

    • event: P
    • listener: Listener<Parameters<TEvents[P][number]>[number]>

    Returns EventEmitter<TEvents>

  • Bind the event that only runs once to the front of the stack.

    Type Parameters

    Type Parameters

    • P extends string | number | symbol

    Parameters

    • event: P
    • listener: Listener<Parameters<TEvents[P][number]>[number]>

    Returns EventEmitter<TEvents>

Generated using TypeDoc