Observable

Observable

An object that emits events. Listeners can bind to specific events and be notified when the event is triggered.

Constructor

new Observable()

Source:

Members

bind

Alias to addCallback.
Source:

trigger

Alias to runCallbackNoWait.
Source:

triggerWait

Alias to runCallbacksWait.
Source:

unbind

Alias to removeCallback.
Source:

Methods

addCallback(event, callback) → {function}

Binds to an event by providing a block that will receive the event payload as a parameter and return a Deferred that will be completed asynchronously.
Source:
Parameters:
Name Type Description
event String Name of the event to bind to.
callback function Function to be executed when the event is triggered.
Returns:
Type:
function
Returns the provided callback, to be used when unbinding from the event.

deinit()

The deinitializer of the class, called whenever this observable ceases its activity.
Source:

removeCallback(event, callback)

Unbinds the provided callback from an event.
Source:
Parameters:
Name Type Description
event String The name of the event.
callback function The callback that was returned when the bind method was called.

runCallbacks(event, wait) → {Promise}

Triggers the event by calling all its bound callbacks with args as parameters.
Source:
Parameters:
Name Type Description
event String The name of the event to be triggered.
wait Boolean If the callback execution should wait for every single execution before running the next one.
Returns:
Type:
Promise
Returns a Promise of all results that will be completed when all of the callbacks have finished processing the triggered event.