Created
August 8, 2015 20:50
-
-
Save danwdart/bd31777c3a6356539934 to your computer and use it in GitHub Desktop.
es6 vs es7
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
// Set up our async runners... | |
let doSomething = () => { | |
return new Promise((resolve,reject) => { | |
console.log('I like this...') | |
setTimeout(() => resolve('hi'), 1000); | |
}); | |
}, | |
appendSomething = (result1) => { | |
return new Promise((resolve,reject) => { | |
console.log('well maybe..') | |
setTimeout(() => resolve(result1 + ' hey there'), 1000); | |
}); | |
} | |
// Plain promises... | |
doSomething() | |
.then(appendSomething) | |
.then((result) => { | |
console.log(result); | |
}); | |
// ES7 | |
async () => { | |
let result = await doSomething(), | |
result2 = await appendSomething(result); | |
console.log(result2) | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment