Last active
December 8, 2018 01:07
-
-
Save antonagestam/b78df0cda2043b63a625a2985091c79d to your computer and use it in GitHub Desktop.
Asynchronous animation loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A slightly more condensed version of https://esdiscuss.org/topic/promises-async-functions-and-requestanimationframe-together | |
*/ | |
let animation_frame = () => new Promise(window.requestAnimationFrame); | |
(async () => { | |
while (true) { | |
await animation_frame(); | |
// draw | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment