Skip to content

EventEmitter.addEventListener

Dragiyski edited this page Mar 28, 2015 · 2 revisions

This method add a new listener or promotes existing one.

Usage

emitter.addEventListener(event, listener, dependencies);

Synonyms

  • on
  • addListener

Arguments

Argument Type Required Description
event string The name of the event.
listener function The listener function added for that event.
dependencies array or array-like object of functions List of dependencies for that listener.

Return

The this EventEmitter instance.

Exceptions

  • Throws a TypeError when listener is not a function.
  • Throws a TypeError when dependencies is array or array-like objects, but contain other than function.
  • Throws a ReferenceError when dependencies contain the listener (e.g. attempt to make listener dependency of itself).

Remarks

If a dependency is not added for as a listener for the given event, it'll be added as long as there are dependent listeners for it.

If listener already added for the specified event, following operation might happen:

  • If a listener is not a normal listener (e.g. added either as dependency or with once), it'll be promoted to normal listener.
  • If a list of dependencies is specified, it'll merged with current dependencies.

Clone this wiki locally