-
-
Save fmarcia/09228e74eca842f3469f9495e82ee701 to your computer and use it in GitHub Desktop.
This file contains 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
const f = (id, fail) => | |
new Promise((y, n) => | |
setTimeout(_ => { | |
console.log(id) | |
fail ? n() : y() | |
}, 100) | |
) | |
const a = _ => | |
new Promise(y => | |
f('a1') | |
.then(_ => f('a2')) | |
.then(_ => f('a3')) | |
.then(y) | |
.catch(y) | |
) | |
const b = _ => | |
new Promise(y => | |
f('b1', 1) | |
.then(_ => f('b2')) | |
.then(_ => f('b3')) | |
.then(y) | |
.catch(y) | |
) | |
const c = _ => | |
new Promise(y => | |
f('c1') | |
.then(_ => f('c2', 1)) | |
.then(_ => f('c3')) | |
.then(y) | |
.catch(y) | |
) | |
{ | |
a() | |
.then(b) | |
.then(c) | |
.then(_ => console.log("success")) | |
.catch(_ => console.log("unreachable")) | |
} |
This file contains 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
a1 | |
a2 | |
a3 | |
b1 | |
c1 | |
c2 | |
success |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment