Skip to content

Instantly share code, notes, and snippets.

@cyrusdavid
Created March 6, 2014 13:55
Show Gist options
  • Save cyrusdavid/9390212 to your computer and use it in GitHub Desktop.
Save cyrusdavid/9390212 to your computer and use it in GitHub Desktop.
sample use case of process.nextTick on node.js
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