v0.8

eventEmitter

object eventEmitter → file: core/lib/eventEmitter.js

Emit or listen the events on an easy way simmilar to NodeJS environment. All events are attached to "window" object.

Instance

Instance of the class EventEmitter exported from the file lib/eventEmitter.js

Properties

Property Description Type Default
activeOns array of listeners defined in .on() method [{eventName:string, listener:Function, listenerWindow:Function}] []

Methods

Use this methods to emit and catch events.

emit(eventName, detail) :void

Create and emit the event.
    ARGUMENTS:
  • eventName :string - event name, for example: 'myCustomEvent'
  • detail :any - event data

on(eventName, listener) :void

Attach the event listener. The listener function will be executed on every catched event.
    ARGUMENTS:
  • eventName :string - event name, for example: 'myCustomEvent'
  • listener :Function - a callback JS function

once(eventName, listener) :void

Attach the event listener. The listener function will be executed only first time on catched event.
    ARGUMENTS:
  • eventName :string - event name, for example: 'myCustomEvent'
  • listener :Function - a callback JS function

off(eventName, listener) :void

Remove the event listener for specific event.
    ARGUMENTS:
  • eventName :string - event name, for example: 'myCustomEvent'
  • listener :Function - a callback JS function

offAll(eventName) :void

Remove all event listeners for specific event.
    ARGUMENTS:
  • eventName :string - event name, for example: 'myCustomEvent'

getListeners(eventName) :void

Get active listeners filtered by eventName, which were defined in the .on().
    ARGUMENTS:
  • eventName :string - event name, for example: 'myCustomEvent'