Created
February 21, 2018 19:38
-
-
Save nilesmc/7ba326f6ba7b1f432de120187277a87e to your computer and use it in GitHub Desktop.
Using ES2017 Async syntax
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
function reachOut(val) { | |
console.log('reach out called with:', val) | |
return new Promise(resolve => { | |
setTimeout(() => { | |
resolve(val); | |
}, 10) | |
}) | |
} | |
async function adderSequence(x) { | |
let a = reachOut(30); | |
let b = reachOut(20); | |
return x + await a + await b; | |
} | |
adderSequence(10).then(val => { | |
console.log(val); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment