Skip to content

Instantly share code, notes, and snippets.

@obbaeiei
Last active July 23, 2018 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obbaeiei/720f6f541b75e4f30fab3ce97805d417 to your computer and use it in GitHub Desktop.
Save obbaeiei/720f6f541b75e4f30fab3ce97805d417 to your computer and use it in GitHub Desktop.
Async on sync
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