Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EventEmitter2

Hierarchy

  • EventEmitter2

Index

Constructors

constructor

Methods

addListener

emit

  • emit(event: string, ...args: any[]): boolean
  • emit(event: string[]): boolean
  • Execute each of the listeners that may be listening for the specified event name in order with the list of arguments.

    Parameters

    • event: string
    • Rest ...args: any[]

    Returns boolean

  • Execute each of the listeners that may be listening for the specified event name in order with the list of arguments.

    Parameters

    • event: string[]

    Returns boolean

listeners

  • listeners(event: string): Function[]
  • Returns an array of listeners for the specified event. This array can be manipulated, e.g. to remove listeners.

    Parameters

    • event: string

    Returns Function[]

listenersAny

  • listenersAny(): Function[]
  • Returns an array of listeners that are listening for any event that is specified. This array can be manipulated, e.g. to remove listeners.

    Returns Function[]

many

  • many(event: string, timesToListen: number, listener: Function): EventEmitter2
  • Adds a listener that will execute n times for the event before being removed. The listener is invoked only the first n times the event is fired, after which it is removed.

    Parameters

    • event: string
    • timesToListen: number
    • listener: Function

    Returns EventEmitter2

off

offAny

on

onAny

once

removeAllListeners

removeListener

  • removeListener(event: string, listener: Function): EventEmitter2

setMaxListeners

  • setMaxListeners(n: number): void
  • By default EventEmitters will print a warning if more than 10 listeners are added to it. This is a useful default which helps finding memory leaks. Obviously not all Emitters should be limited to 10. This function allows that to be increased. Set to zero for unlimited.

    Parameters

    • n: number

    Returns void