Skip to content

Instantly share code, notes, and snippets.

@oieioi
Created June 26, 2015 06:45
Show Gist options
  • Save oieioi/9309a39976d0b0d4b70f to your computer and use it in GitHub Desktop.
Save oieioi/9309a39976d0b0d4b70f to your computer and use it in GitHub Desktop.
event call
var EventEmitter = require('events').EventEmitter;
var inherits = require('util').inherits;
var Callee = function(){};
inherits(Callee, EventEmitter);
var o = new Callee();
o.on('first', function(){
console.log('first');
});
o.on('second', function(){
console.log('second');
});
var o2 = new Callee();
o2.on('all', function(){
console.log('all');
console.log('emit o\'s first');
o.emit('first');
console.log('emit o\'s second');
o.emit('second');
});
o2.emit('all');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment