shajara图解单次 Spawn
中文

单次 Spawn

spawned work 独立运行

spawn(sendReceiptEmail)submitOrderpendingsendReceiptEmailpending
function* submitOrder() {
  yield* spawn(function* sendReceiptEmail() {
    yield* sleep(1000);
    return "receipt sent";
  });

  return "order accepted";
}
submitOrder 把 sendReceiptEmail 启动为 spawned process。
submitOrder 不等待 sendReceiptEmail,直接返回 order accepted。