Skip to content

Instantly share code, notes, and snippets.

@tamg
Created February 25, 2017 23:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamg/829a2981ed5f1e3371ad4be236e059a1 to your computer and use it in GitHub Desktop.
Save tamg/829a2981ed5f1e3371ad4be236e059a1 to your computer and use it in GitHub Desktop.
//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