Promises, async functions, and requestAnimationFrame, together.

/#!/JoePea joe at
Fri Apr 22 23:38:41 UTC 2016

Is it possible?

 I thought maybe something like this:

function animationFrame() {
    let resolve = null
    const promise = new Promise(r => resolve = r)
    return promise

async function game() {
    // the game loop
    while (true) {
        await animationFrame()


But, I'm not sure what to expect: does the code that follows the await
statement execute in the frame, sometimes in the frame, or never in
the frame? What might we expect from the various browsers?

More information about the es-discuss mailing list