Working with events

Every time the Oahu component has to handle API calls, events are generated. An event is represented by a message and an object holding the data returned by the API call.

For example this call will generate 2 events with ‘start’ and ‘success’ or ‘error’) :

Oahu.connect.getLoginStatus("Facebook");

Message format

A message is sent as a string in the following format :

providerName:moduleName:methodName:status

Where :

Binding an event

To do so, just use the following method on the Oahu client :

bind( expr , callback)

Where :

Here is an example on how to bind envents on the init callback :

Oahu.init({}, function(client) {
  client.bind('connect:getLoginStatus:(success|error)', function(message, data) {
    // do something
  });
})

This binding will be called when any provider returns the login status with a success or an error.