Created
June 26, 2015 06:45
-
-
Save oieioi/9309a39976d0b0d4b70f to your computer and use it in GitHub Desktop.
event call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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