async-promise-then-destructured-param.ts 500 B

12345678910
  1. // .then callback with a DESTRUCTURED parameter over a join result: at runtime
  2. // x is alpha's output and y is beta's output, both feeding the merger ask.
  3. // Expected: ask#1 -> join#1 port=0; ask#2 -> join#1 port=1;
  4. // ask#1 -> ask#3; ask#2 -> ask#3; join#1 -> ask#3; ask#3 -> sink.
  5. const pair = Promise.all([
  6. agent("alpha").ask<string>("a"),
  7. agent("beta").ask<string>("b"),
  8. ]);
  9. const combined = await pair.then(([x, y]) => agent("merger").ask<string>(`merge ${x} and ${y}`));
  10. return combined;