Re: Open Source Cross-Browser setImmediate in JavaScript

On 7/7/11 10:11 AM, Paul Bakaus wrote:
> That's the thing  I'm wondering out the same thing, so I'd love to know
> where the difference really is. setTimeout often feels to slow  for
> instance, to start or restart CSS animations or transitions, you have to
> wait for a relayout, which is where I'm using setTimeout.

Of course that doesn't actually work correctly, per 
unless you use a pretty long timeout value...

> My guess is that setImmediate wouldn't wait for layout batches to be
> finished, but only JS

If it's running on the same event loop as layout (which as far as I can 
tell it is), then it would have to wait for layout to not be running.

> so you might call it while code is executing and
> would know it's executed right after the rest of your current stack has
> been worked off, but before layout changes.

I don't think it offers any such guarantees.  Certainly not as currently 

Note that layout can change synchronously if something flushes it, by 
the way, so there's no async setup that can guarantee running before 
layout changes.


Received on Thursday, 7 July 2011 15:37:32 UTC