Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 14039bf

Browse files
enhancedEventEmitter
0 parents commit 14039bf

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

‎application.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
global.api = {};
4+
require('./events.js');
5+
6+
global.application = api.events.enhancedEventEmitter();
7+
8+
application.on('smth', function(data) {
9+
console.dir(data);
10+
});
11+
12+
application.on('*', function(name, data) {
13+
console.dir([name, data]);
14+
});
15+
16+
application.emit('smth', { a: 5 });

‎events.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
api.events = require('events');
4+
5+
api.events.enhancedEventEmitter = function() {
6+
var ee = new api.events.EventEmitter(),
7+
emit = ee.emit;
8+
ee.emit = function() {
9+
var args = [];
10+
Array.prototype.push.apply(args, arguments);
11+
args.unshift('*');
12+
emit.apply(ee, args);
13+
emit.apply(ee, arguments);
14+
};
15+
return ee;
16+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /