Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. function main() {
  2. const a = computeA();
  3. const b = computeB(a); // Say: computeB takes promise in input.
  4. const c = go(async cb => computeC(await b, cb)); // Say: computeC doesn't understand promise.
  5. const d = computeD(a, c); // Say: computeD takes promise in input.
  6. const e = computeE(b); // etc.
  7. const f = go(async cb => computeF(await b, await c, cb));
  8. const g = computeG(d)
  9. const h = computeH(d, f);
  10. const i = computeI(g);
  11. const j = go(async cb => computeJ(await g));
  12.  
  13. // Usually just await j is enough if that is the final result you are interested in.
  14. return Promises.all([a, b, c, d, e, f, g, h, i, j]).then((res) => {
  15. console.log("All done");
  16. }, (err) => {
  17. console.error(err);
  18. })
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement