API. Events

new Events()

Methods

cleanEvents(eventName)

removes all the subscriptions with a given event name.

Parameters:
NameTypeDescription
eventNamestring

Optional Name of the event

off(eventName, callbackopt) → {boolean}

Removes the subscriptions with a given event name.

Parameters:
NameTypeAttributesDescription
eventNamestring

Name of the event.

callbackfunction<optional>

Optional Function to be removed from the event's callbacks

Returns:
  • True if the callback was removed, false if it was not found
Type: 
boolean

on(eventName, callback)

Subscribes to controller resource with a given event name

Parameters:
NameTypeDescription
eventNamestring

Name of the event

callbackfunction

Function to be called when event is triggered

once(eventName, callback) → {boolean}

Subscribe to an event, but the callback is called only once

Parameters:
NameTypeDescription
eventNamestring

Name of the triggering event

callbackfunction

Function to be called when the event is triggered

Returns:
  • True if the callback was added, false if it was already added
Type: 
boolean

trigger(eventName, data)

Triggers all the callback functions that have subscribed to an event.

Parameters:
NameTypeDefaultDescription
eventNamestring

Name of the event to be triggered

dataanynull

Data passed to the callback as input parameter