Created
June 30, 2020 14:44
-
-
Save Quickz/325707653eda735839713a99eae1cf96 to your computer and use it in GitHub Desktop.
Asynchronous loop with a delay between iterations
This file contains hidden or 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
doStuff(); | |
async function doStuff() | |
{ | |
while (true) | |
{ | |
console.log("Hello, world!"); | |
await sleep(500); | |
} | |
} | |
function sleep(milliseconds: number) | |
{ | |
return new Promise(resolve => setTimeout(resolve, milliseconds)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment