Created
July 11, 2017 19:30
-
-
Save mkjiau/9172bb0a8a2c7499d6ee3272ed7b4a5c 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
var apif1 = () => new Promise((resolve, reject) => { | |
setTimeout(resolve, 1000, "one"); | |
}); | |
var apif2 = () => new Promise((resolve, reject) => { | |
setTimeout(resolve, 2000, "two"); | |
}); | |
var apif3 = (values) => new Promise((resolve, reject) => { | |
var flattened = values.reduce((acc, val) => acc.concat(val)); | |
setTimeout(resolve, 3000, flattened); | |
}); | |
const combineTwo = async () => { | |
const r1 = await apif1(); | |
const r2 = await apif2(); | |
const r3 = await apif3([r1, r2]); | |
console.log(r3); | |
}; | |
combineTwo(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment