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 () {});