Created
March 6, 2014 13:55
-
-
Save cyrusdavid/9390212 to your computer and use it in GitHub Desktop.
sample use case of process.nextTick on node.js
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
function Foo() { | |
var self = this; | |
require('events').EventEmitter.call(arguments, this); | |
// process.nextTick(function() { | |
self.emit('foo'); | |
// }); | |
} | |
require('util').inherits(Foo, require('events').EventEmitter); | |
var foo = new Foo(); | |
foo.on('foo', function() { | |
require('util').log('foo'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment