Last active
July 23, 2018 15:34
-
-
Save obbaeiei/720f6f541b75e4f30fab3ce97805d417 to your computer and use it in GitHub Desktop.
Async on sync
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 add(a, b) { | |
return a + b | |
} | |
async function mainBad() { | |
await add(1, 2) // bad | |
console.log('finished') | |
} | |
function mainGood() { | |
add(1, 2) // good | |
console.log('finished') | |
} | |
async function mainGood02() { | |
const number = await Promise.resolve(10) // good | |
console.log(number) | |
} | |
mainBad() | |
mainGood() | |
mainGood02() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment