Skip to content

Instantly share code, notes, and snippets.

@jackey
Created December 1, 2011 08:06
Show Gist options
  • Save jackey/1414846 to your computer and use it in GitHub Desktop.
Save jackey/1414846 to your computer and use it in GitHub Desktop.
process.nextTick
var MyConstructor = function() {
...
process.nextTick(function() {
self._continue();
});
};
MyConstructor.prototype.__proto__ = EventEmitter.prototype;
MyConstructor.prototype._continue = function() {
// without the process.nextTick
// these events would be emitted immediately
// with no listeners. they would be lost.
this.emit('data', 'hello');
this.emit('data', 'world');
this.emit('end');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment