Effection Logo

function useScope

thefrontside/effection

function* useScope(): Operation<Scope>

Get the scope of the currently running Operation.

Examples

Example 1

import { sleep, useScope } from "effection";

let scope = yield* useScope();
let task = yield* scope.spawn(function* () {
  yield* sleep(100);
  return "done";
});

// task is attached to the current scope and cannot outlive it
console.log(yield* task);

Return Type

Operation<Scope>

an operation yielding the current scope