Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor correction to the last code snippet.

  • Loading branch information...
commit c1fc36611e57b61203d1856366a28f322e65d123 1 parent 4bf658d
@kishorenc kishorenc authored
Showing with 5 additions and 1 deletion.
  1. +5 −1 articles/understanding-process-next-tick.markdown
View
6 articles/understanding-process-next-tick.markdown
@@ -88,6 +88,8 @@ We can correct `asyncFake()` to be always asynchronous this way:
Let's say you are writing a library that reads from a source and emits events that contains the chunks that are read. Such a library might look like this:
+ var EventEmitter = require('events').EventEmitter;
+
function StreamLibrary(resourceName) {
this.emit('start');
@@ -112,8 +114,10 @@ In the above example, the listener will never get the `start` event as that even
function StreamLibrary(resourceName) {
+ var self = this;
+
process.nextTick(function() {
- this.emit('start');
+ self.emit('start');
});
// read from the file, and for every chunk read, do:
Please sign in to comment.
Something went wrong with that request. Please try again.