const p1 = Promise.resolve('twenty-two');
const p2 = Promise.resolve(22);
const p3 = Promise.reject('Doh');
Promise.race([p1, p2, p3])
.then(function fulfilled(value) {
console.log(value);
})
// twenty-two
Promise.all([p1, p2, p3])
.then(
function fulfilled(msgs) {
console.log(msgs);
},
function rejected(error) {
console.log(error);
}
)
// doh
Promise.all([p1, p2])
.then(
function fulfilled(msgs) {
console.log(msgs);
},
function rejected(error) {
console.log(error);
}
)
// ["twenty-two", 22]
Last active
June 11, 2018 14:39
-
-
Save amysimmons/6015a40c1b2f82066d6477e6dd87f19b to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment