Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/effection/lib/run/scope.ts>createScope

Structured concurrency and effects for JavaScript
Go to Latest
function createScope
import { createScope } from "https://deno.land/x/effection@3.0.3/lib/run/scope.ts";

Create a new scope to serve as an entry point from normal JavaScript execution into Effection.

When creating a fresh scope (as opposed to capturing a reference to an existing one via useScope) it is the responsibility of the creator of the new scope to destroy it when it is no longer needed.

Examples

Example 1

let [scope, destroy] = createScope();
let task = scope.run(function*() {
  //do some long running work
});

//... later
await destroy();

Parameters

optional
frame: Frame

Returns

[Scope, () => Future<void>]

a tuple containing the new scope, and a function to destroy it.