Skip to content

Instantly share code, notes, and snippets.

@noppolp
Created May 18, 2015 16:25
Show Gist options
  • Select an option

  • Save noppolp/d68ca01562ad4abcae67 to your computer and use it in GitHub Desktop.

Select an option

Save noppolp/d68ca01562ad4abcae67 to your computer and use it in GitHub Desktop.
EvenEmitter on NodeJS
var EventEmitter = require('events').EventEmitter;
var doSomething = function () {
var result = new EventEmitter();
setTimeout(function () {
result.emit('success', 'Hello World!');
}, 1000);
return result;
};
doSomething().on('success', function (msg) {
console.log(msg);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment