eventhandling

Summary
eventhandling
Functions
addEventListenerInstall an event handler for the given event name
removeEventListenerRemove a previously installed event handler
eventhandling.onAlias for addEventListener
eventHandlingMixes event handling functionality into an object.

Functions

addEventListener

addEventListener: function(eventName,
handler)

Install an event handler for the given event name

removeEventListener

removeEventListener: function(eventName,
handler)

Remove a previously installed event handler

eventhandling.on

eventHandling

RemoteStorage.eventHandling = function(object)

Mixes event handling functionality into an object.

The first parameter is always the object to be extended.  All remaining parameter are expected to be strings, interpreted as valid event names.

Example

var MyConstructor = function() {
  eventHandling(this, 'connected', 'disconnected');

  this._emit('connected');
  this._emit('disconnected');
  // This would throw an exception:
  // this._emit('something-else');
};

var myObject = new MyConstructor();
myObject.on('connected', function() { console.log('connected'); });
myObject.on('disconnected', function() { console.log('disconnected'); });
// This would throw an exception as well:
// myObject.on('something-else', function() {});
addEventListener: function(eventName,
handler)
Install an event handler for the given event name
removeEventListener: function(eventName,
handler)
Remove a previously installed event handler
RemoteStorage.eventHandling = function(object)
Mixes event handling functionality into an object.
Close