Node.js version 0.10 was released today and introduced setImmediate
. The API changes documentation suggests using it when doing recursive nextTick
I recommend you to check docs section dedicated for Loop to get better understanding. Some snippet taken from there:
We have two calls that are similar as far as users are concerned, but their names are confusing.
process.nextTick() fires immediately on the same phase
setImmediate() fires on the following iteration or 'tick' of the
event loop
In essence, the names should be swapped. process.nextTick() fires more immediately than setImmediate(), but this is an artifact of the past which is unlikely to change.