Support Meteor.defer in inactive iOS tabs. #1023
In iOS Safari,
This implementation uses the native
Factors out some common code in
In iOS Safari, `setTimeout` and `setInterval` events are not delivered to inactive tabs (unless and until they become active again). This means that using `setTimeout(fn, 0)` to run `fn` in the next event loop can in fact delay `fn` indefinitely. This implementation uses the native `setImmediate` (when available) or `postMessage` (all other modern browsers); falling back to `setTimeout` if the first two aren't available. The `qa` subdirectory includes a manual test to check that `defer` is working in inactive tabs. (Sadly the test can't run automatically because scripts aren't allowed to open child windows except in response to user events). Factors out some common code in `timers.js`.
I ended up just using the