Potentially outdated documentation
You're reading API reference for version 3.3.0. The latest stable release is version 3.4.0.
function scoped
thefrontside/effectionfunction scoped<T>(operation: () => Operation<T>): Operation<T>
Encapsulate an operation so that no effects will persist outside of it. All active effects such as concurrent tasks and resources will be shut down, and all contexts will be restored to their values outside of the scope.
Examples
Example 1
import { useAbortSignal } from "effection";
function* example() {
let signal = yield* scoped(function*() {
return yield* useAbortSignal();
});
return signal.aborted; //=> true
}
Type Parameters
T
Parameters
operation: () => Operation<T>
- the operation to be encapsulated
Return Type
Operation<T>
the scoped operation