function run
thefrontside/effectionfunction run<T>(operation: () => Operation<T>): Task<T>
Execute an operation.
Run is an entry point into Effection, and is especially useful when embedding Effection code into existing code. However, If you are writing your whole program using Effection, you should prefer https://effection-www-pggsafb7y58a.deno.dev/api/v4/main.
Examples
Example 1
import { run, useAbortSignal } from 'effection';
async function fetchExample() {
await run(function*() {
let signal = yield* useAbortSignal();
let response = yield* fetch('http://www.example.com', { signal });
yield* response.text();
});
});
Run will create a new top-level scope for the operation. However, to run an operation in an existing scope, you can use https://effection-www-pggsafb7y58a.deno.dev/api/v4/Scope.
Type Parameters
T
Parameters
operation: () => https://effection-www-pggsafb7y58a.deno.dev/api/v4/Operation<T>
the operation to run
Return Type
https://effection-www-pggsafb7y58a.deno.dev/api/v4/Task<T>
a task representing the running operation.