Last active
August 29, 2015 14:16
-
-
Save joerx/436b57ea5c8772e0d16c to your computer and use it in GitHub Desktop.
EventEmitter
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 emitter = new EventEmitter(); | |
var obj = Object.create(EventEmitter.prototype); | |
obj.say = function say() { | |
obj.emit('hello'); | |
} | |
obj.on('e', function() { | |
console.log('echo'); | |
}); | |
obj.on('hello', function() { | |
console.log('hello'); | |
}); | |
obj.emit('e'); | |
obj.say(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment