shajaraExplorerScope-Owned Work
English

Scope-Owned Work

child-scope work convergence

branch(commitArticle)spawn(updateSearchIndex)owned processbranch waits for child scopepublishArticlependingupdateSearchIndexpendingcommitArticlepending
function* publishArticle() {
  const result = yield* branch(function* commitArticle() {
    yield* spawn(function* updateSearchIndex() {
      yield* sleep(1000);
    });

    return "published";
  });

  return result;
}
publishArticle enters branch to run commitArticle, then returns its result.
branch creates a child scope that owns work spawned inside the boundary.
commitArticle produces published before updateSearchIndex finishes.
branch waits for scope-owned work before returning.