Created
April 28, 2023 20:51
-
-
Save epreston/ad411854d74c05a447e92e611334e502 to your computer and use it in GitHub Desktop.
promise based delay - runs async after paint
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
function resolveAfter(ms) { | |
// intoduces a delay | |
return new Promise((resolve) => setTimeout(resolve, ms)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uses setTimeout (runs async after paint).
Different from:
Useful for ensuring DOM updates, animations, general script delays to allow other things to complete.
Examples: