3 ms·
Here is a complex dependency graphs built with no nesting and no "special" methods, only a combination of `then` and `all` function test(name1, name2) {
by spion 10y ago
Here is a complex dependency graphs built with no nesting and no "special" methods, only a combination of `then` and `all`
function test(name1, name2) {
let user1 = User.find(name1)
let user2 = User.find(name2)
let post1 = user1.then(u => Posts.getLast(u.id))
let post2 = user2.then(u => Posts.getLast(u.id))
let comparison = Promise.all([post1, post2])
.then(([p1, p2]) => DiffService.compare(p1, p2))
let email1 = Promise.all([user1, comparison])
.then(([u1, c]) => Email.send(comparison.text(), u1.email))
let email2 = Promise.all([user2, comparison])
.then(([u2, c]) => Email.send(comparison.text() ,u2.email))
return Promise.all([email1, email2])
}