Namespace: Events

Events

Each application raises a set of default events on which listeners could be attached.


Built.io Backend The SDK triggers some global events for the developers. Here is the list of triggered events:

  • http:start - any http request is initiated
  • http:end - at the completion of http request
  • upload:start - any upload is initiated
  • upload:end - at the completion of upload
  • user:register - at the completion of user registration
  • user:activate - at the completion of user activation request
  • user:deactivate - at the completion of user deactivation request
  • user:login - at the completion of login request
  • user:logout - at the completion of logout request
  • user:save-session - at the time saveSession is invoked
  • user:clear-session - at the time clearSession is invoked

Example

var Events = Built.Events;

Methods

staticEvents.off(eventName, listener)

events.js, line 72
Removes a specific listener if the listener is provided. Else it removes all the listeners that were registered.
Name Type Description
eventName String The event from which the listener is to be removed
listener function The listener function
Example
var listener1 = function(data){
   // do something here
};
var listener2 = function(data){
   // do something here
};
var Events = Built.Events;
Events.on('user:login',listener1);     //Registers a listener on user:login
Events.on('user:login',listener2);     //Registers another listener on user:login

Evetns.off('user:login',listener1);    //Unregisters a single listener
Events.off('user:login');              //Unregisters all listeners that were registered   

staticEvents.on(eventName, listener)

events.js, line 53
Attach a listener for an event
Name Type Description
eventName String The event on which a listener should be attached
listener function The callback function to be invoked
Example
var Events = Built.Events;
Evetns.on('user:login',function(data){
   // do something here
});