forked from Meteor-Community-Packages/ground-db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrap.proto.eventemitter.js
33 lines (26 loc) · 1.38 KB
/
wrap.proto.eventemitter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//////////////////////////////////////////////////////////////////////////////
// WRAP EVENTEMITTER API on prototype
//////////////////////////////////////////////////////////////////////////////
// Wrap the Event Emitter Api "on"
_groundUtil.Collection.prototype.on = function(/* arguments */) {
return this.eventemitter.on.apply(this.eventemitter, _.toArray(arguments));
};
// Wrap the Event Emitter Api "once"
_groundUtil.Collection.prototype.once = function(/* arguments */) {
return this.eventemitter.once.apply(this.eventemitter, _.toArray(arguments));
};
// Wrap the Event Emitter Api "off"
_groundUtil.Collection.prototype.off = function(/* arguments */) {
return this.eventemitter.off.apply(this.eventemitter, _.toArray(arguments));
};
// Wrap the Event Emitter Api "emit"
_groundUtil.Collection.prototype.emit = function(/* arguments */) {
return this.eventemitter.emit.apply(this.eventemitter, _.toArray(arguments));
};
// Add api helpers
_groundUtil.Collection.prototype.addListener = _groundUtil.Collection.prototype.on;
_groundUtil.Collection.prototype.removeListener = _groundUtil.Collection.prototype.off;
_groundUtil.Collection.prototype.removeAllListeners = _groundUtil.Collection.prototype.off;
// Add jquery like helpers
_groundUtil.Collection.prototype.one = _groundUtil.Collection.prototype.once;
_groundUtil.Collection.prototype.trigger = _groundUtil.Collection.prototype.emit;