Skip to content

Commit

Permalink
Move setImmediate closer to sync event
Browse files Browse the repository at this point in the history
> EventEmitter was made to be used as an abstraction around asynchronous events. Thus, when an event is emitted it will have happened on a different tick than when the event was set.

See nodejs/node-v0.x-archive#8470 (comment)
  • Loading branch information
floatdrop committed Jul 16, 2015
1 parent 16f93ea commit a1eb3f7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ function requestAsEventEmitter(opts) {
timedOut(req, opts.timeout);
}

ee.emit('request', req);
setImmediate(ee.emit.bind(ee), 'request', req);
}

setImmediate(get, opts); // quirk to attach event listeners
get(opts);
return ee;
}

Expand Down

0 comments on commit a1eb3f7

Please sign in to comment.