kriskowal/q — Issue #50: Consider using `setImmediate` if available
Author: domenic
Created: 2012-02-23 14:23:28+00:00
State: open

`global.setImmediate` is a proposed-for-standardization version of `Q.nextTick`.

It does not seem to be winning the battle for the hearts and minds of spec editors (MDN says "is not expected to become standard"; negative comments from Hixie in a related bug). But, it does seem to be winning the hearts and minds of developers (blog post from Nicholas Zakas; dependencies from a reasonably-popular Knockout.js plugin; even a (closed) bug to use it in underscore.js). So it might get somewhere in the end, and Q's support could help push things in that direction.

Currently the only way to get it is through manually shimming it; the only browser to have it natively is IE9, and there it's hidden behind a prefix. So if we said `Q.nextTick = global.setImmediate || (existing code)`, this would only work for people who have included a shim.

Still, this seems like a win. For shim users, it gives faster promises in non-`MessageChannel`-supporting browsers. It would also solve #44, by allowing users in the add-on SDK environment to do a quick shim like `global.setImmediate = require("event-queue").enqueue`.

What do you think?