Skip to content Skip to sidebar Skip to footer

Are Microtasks Guaranteed To Fire Within The Same Animation Frame Where They Were Queued?

For example, Promises use microtasks, and I verified here that they can be fullfilled before an animation frame is over (in Chrome). I am talking about frames made with requestAnim

Solution 1:

seems like it is

try

functiona() {
    requestAnimationFrame(b=>{
        console.log(b, 'rAF');
        Promise.resolve(1).then(()=>console.log('promise'));
    })}
a();a();

and you will get

585838.7970909999 rAF
promise
585838.7970909999 rAF
promise

Post a Comment for "Are Microtasks Guaranteed To Fire Within The Same Animation Frame Where They Were Queued?"