Repository

EventEmitter

EventEmitter is a helper class to handle event emission

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public

scope: *

Method Summary

Public Methods
public

off(type: String, callback: Function): *

Remove an event listener

public

on(type: String, callback: Function): *

Add an event listener

public

trigger(type: String): *

Trigger an event

Public Constructors

public constructor(params: Object) source

Params:

NameTypeAttributeDescription
paramsObject

Parameters object, given by the constructor.

params.scopeMixed
  • optional

The scope to use for callbacks, should usually be set to the class instance using the EventEmitter. Defaults to the EventEmitter instance if not specified

Public Members

public listeners: {} source

public scope: * source

Public Methods

public off(type: String, callback: Function): * source

Remove an event listener

Params:

NameTypeAttributeDescription
typeString

The event type to stop listen to

callbackFunction
  • optional

The callback function associated with the listener. If not specified, all listeners will be removed

Return:

*

public on(type: String, callback: Function): * source

Add an event listener

Params:

NameTypeAttributeDescription
typeString

The event type to listen to

callbackFunction

The callback to call when the event is captured

Return:

*

public trigger(type: String): * source

Trigger an event

Params:

NameTypeAttributeDescription
typeString

The event type

...dataMixed
  • optional

Data to send along with the event

Return:

*