Skip to content

Instantly share code, notes, and snippets.

@rochapablo
Created July 26, 2018 17:09
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 rochapablo/e439604ba1c3b9ebc6c3e145b6ea9501 to your computer and use it in GitHub Desktop.
Save rochapablo/e439604ba1c3b9ebc6c3e145b6ea9501 to your computer and use it in GitHub Desktop.
Promise Tuple
(function() {
console.clear()
const a = () => {
return Promise.resolve({ value: 'a' })
}
const b = () => {
return Promise.resolve({ value: 'b' })
}
const c = () => {
return Promise.resolve({ value: 'c' })
}
const d = a()
.then((resa) => b()
.then((resb) => c()
.then((resc) => [resa, resb, resc])))
// .then(([resa, resb, resc]) => console.log(resa, resb, resc))
// .then(([resa, resb, resc]) => { return [resa, resb, resc] })
.then(([resa, resb, resc]) => [resa, resb, resc])
d.then((res) => console.log(res))
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment