Created
February 25, 2017 23:00
-
-
Save tamg/829a2981ed5f1e3371ad4be236e059a1 to your computer and use it in GitHub Desktop.
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
//grab the Event Emitter from the events module | |
var Emitter = require('events'); | |
//create our own instance of an Emitter | |
var emtr = new Emitter(); | |
//create a new event and response on our listener | |
emtr.on('greet', function() { | |
console.log('A greeting occurred!'); | |
}); | |
//emit an event manually | |
emtr.emit('greet'); | |
//emtr, which was listening to a 'greet' event responds with | |
// 'A greeting occurred!' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment