forked from Meteor-Community-Packages/ground-db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrap.eventemitter.js
36 lines (28 loc) · 1.09 KB
/
wrap.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
34
35
36
//////////////////////////////////////////////////////////////////////////////
// WRAP EVENTEMITTER API on Ground
//////////////////////////////////////////////////////////////////////////////
// Add a top level event emitter
Ground.eventemitter = new EventEmitter();
// Wrap the Event Emitter Api "on"
Ground.on = function(/* arguments */) {
Ground.eventemitter.on.apply(Ground.eventemitter, _.toArray(arguments));
};
// Wrap the Event Emitter Api "once"
Ground.once = function(/* arguments */) {
Ground.eventemitter.once.apply(Ground.eventemitter, _.toArray(arguments));
};
// Wrap the Event Emitter Api "off"
Ground.off = function(/* arguments */) {
Ground.eventemitter.off.apply(Ground.eventemitter, _.toArray(arguments));
};
// Wrap the Event Emitter Api "emit"
Ground.emit = function(/* arguments */) {
Ground.eventemitter.emit.apply(Ground.eventemitter, _.toArray(arguments));
};
// Add api helpers
Ground.addListener = Ground.on;
Ground.removeListener = Ground.off;
Ground.removeAllListeners = Ground.off;
// Add jquery like helpers
Ground.one = Ground.once;
Ground.trigger = Ground.emit;