Skip to content

Instantly share code, notes, and snippets.

@tamg
Created Feb 25, 2017
Embed
What would you like to do?
//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