Scope-Owned Work
Work owned by a child scope must finish before the caller continues.
function* publishArticle() {
const result = yield* branch(function* commitArticle() {
yield* spawn(function* updateSearchIndex() {
yield* sleep(1000);
});
return "published";
});
return result;
}publishArticle calls branch(...), opening the commitArticle child scope.
updateSearchIndex is spawned inside the commitArticle scope.
commitArticle returns published before updateSearchIndex finishes.
publishArticle continues from branch(...) only after updateSearchIndex finishes.