I have seen process.nextTick
used in a few places and can't quite tell what it's being used for.
- https://github.com/andrewvc/node-paperboy/blob/master/lib/paperboy.js#L24
- https://github.com/substack/node-browserify/blob/master/index.js#L95
What are the main/proper use cases of process.nextTick
in Node.js? The docs basically say it's a more optimized way of doing setTimeout
, but that doesn't help much.
I used to do a lot of ActionScript, so the idea of "waiting until the next frame" to execute code makes sense on some level - if you're running an animation you can have it update every frame rather than every millisecond for example. It also makes sense when you want to coordinate setting a bunch of variables - you change the variables in frame 1, and apply the changes in frame 2. Flex implemented something like this in their component lifecycle.
My question is, what should I be using this for in server-side JavaScript? I don't see any places right off the bat where you'd need this kind of fine-tuned performance/flow control. Just looking for a point in the right direction.