method-shorthand.ts 346 B

1234567891011
  1. // Object-literal shorthand method: `obj.run(s)` must bind s to the method's param
  2. // and route it into the inner worker ask.
  3. const worker = agent("worker");
  4. const s = await agent("s").ask<string>("seed");
  5. const obj = {
  6. run(x: string): Node<string> {
  7. return worker.ask<string>(`process ${x}`);
  8. },
  9. };
  10. const r = await obj.run(s);
  11. return r;