Created
May 18, 2015 16:25
-
-
Save noppolp/d68ca01562ad4abcae67 to your computer and use it in GitHub Desktop.
EvenEmitter on NodeJS
This file contains hidden or 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 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