Last active
March 29, 2018 10:31
-
-
Save bryanjknight/819f6b1ade6c5677b8ad57d04da5a49d to your computer and use it in GitHub Desktop.
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
'use strict'; | |
async function doSomething(waitTime) { | |
// because setTimeout does not return a promise (yet) | |
// we have to wrap it in a promise and wait for it to resolve | |
return new Promise(function(resolve) { | |
setTimeout(resolve, waitTime); | |
}); | |
} | |
async function doEverything() { | |
let result = await doSomething(1000); | |
console.log(`Result #1: ${result}`); | |
result = await doSomething(2000); | |
console.log(`Result #2: ${result}`); | |
} | |
doEverything(); | |
console.log('kicked off doEverything'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment