Promises, async functions, and requestAnimationFrame, together.

/#!/JoePea joe at trusktr.io
Sat Mar 18 21:11:51 UTC 2017


Ah, I think the reason that this animation loop using promises works is
because promise handlers resolve in the next microtask after the current
macrotask. I believe that the animation frame fires in what is essentially
a macrotask, then immediately after this macrotask the resolution of the
`animationFrame()` promise happens in the following microtask. At some
point later, the browser renders stuff, which I think might the next
macrotask after the animation frame macrotask.

*/#!/*JoePea
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170318/6756b629/attachment.html>


More information about the es-discuss mailing list