Interface EventModule

{@link http://github.com/hij1nx/EventEmitter2}

Index

Methods

Methods

public addListener(event: string, listener: Function): EventModule

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

Parameters

  • event: string
  • listener: Function

Returns

EventModule

public emit(event: string, args?: Array<any>): any

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

Parameters

  • event: string
  • args?: Array<any> optional

Returns

any

public listeners(event: string): Array<Function>

Returns an array of listeners for the specified event. This array can be manipulated, e.g. to remove listeners.

Parameters

  • event: string

Returns

Array<Function>

public listenersAny(): Array<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

Array<Function>

public many(event: string, timesToListen: number, listener: Function): EventModule

Adds a listener that will execute n times for the event before being removed. The listener is invoked only the first time the event is fired, after which it is removed.

Parameters

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

Returns

EventModule

public off(event: string, listener: Function): EventModule

Parameters

  • event: string
  • listener: Function

Returns

EventModule

public offAny(listener: Function): EventModule

Removes the listener that will be fired when any event is emitted.

Parameters

  • listener: Function

Returns

EventModule

public on(event: string, listener: Function): EventModule

Parameters

  • event: string
  • listener: Function

Returns

EventModule

public onAny(listener: Function): EventModule

Adds a listener that will be fired when any event is emitted.

Parameters

  • listener: Function

Returns

EventModule

public once(event: string, listener: Function): EventModule

Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed.

Parameters

  • event: string
  • listener: Function

Returns

EventModule

public removeAllListeners(event: string): EventModule

Removes all listeners, or those of the specified event.

Parameters

  • event: string

Returns

EventModule

public removeListener(event: string, listener: Function): EventModule

Remove a listener from the listener array for the specified event. Caution: changes array indices in the listener array behind the listener.

Parameters

  • event: string
  • listener: Function

Returns

EventModule

public setMaxListener(n: number)

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