Class EventEmitter<CustomEvents>

Type Parameters

Hierarchy (View Summary)

Constructors

Methods

  • Type Parameters

    • Type extends string | number | symbol
    • Callback extends (...args: any) => void

    Parameters

    Returns this

    adds a listener to the end of the listeners array for the specified event.

  • Type Parameters

    • Type extends string | number | symbol
    • Callback extends (...args: any) => void

    Parameters

    Returns boolean

    execute each of the listeners in order with the supplied parameters.

  • Type Parameters

    • Type extends string | number | symbol
    • Callback extends (...args: any) => void

    Parameters

    Returns Callback[]

    returns an array of listeners for the specified event.

  • Type Parameters

    • Type extends string | number | symbol
    • Callback extends (...args: any) => void

    Parameters

    Returns this

    alias for addListener

  • Type Parameters

    • Type extends string | number | symbol
    • Callback extends (...args: any) => void

    Parameters

    Returns this

    adds a one time listener for the event. This listener is invoked only the next time the event is fired, after which it is removed.

  • Type Parameters

    • Type extends string | number | symbol

    Parameters

    Returns this

    removes all listeners, or those of the specified event.

  • Type Parameters

    • Type extends string | number | symbol
    • Callback extends (...args: any) => void

    Parameters

    Returns this

    remove a listener from the listener array for the specified event.

  • Parameters

    • maxListeners: number

    Returns this

    by default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default which helps finding memory leaks. Obviously not all Emitters should be limited to 10. This function allows that limit to be increased. Set to zero for unlimited.

  • Parameters

    • cb: Function

    Returns void

    set custom error handler for event listeners

  • Parameters

    • maxListeners: number

    Returns void

    set default amount for limit warning