32
loading...
This website collects cookies to deliver better user experience
const nextFrame = () =>
new Promise(resolve => requestAnimationFrame(resolve));
(async function animate() {
while (true) {
// ... maybe we should add an exit/break condition
// lovely in-control-render-loop
await nextFrame();
}
})();
Ironically you might never notice this as some implementations do cover the case. See Timing of microtask triggered from requestAnimationFrame
.then
is always deferred. Otherwise,// not runnable code, for illustration purpose
aMaybeSyncPromise.then((x)=>{
// assume an error is thrown in callback
throw 'Oops!!';
// or access a closure variable
doSomething(y); // 'y' is undefined if sync
});
// ... original flow of control
let y;
// ...