import { call } from "https://deno.land/x/effection@4.0.0-alpha.1/lib/call.ts";
Pause the current operation, async function, plain function, or operation function. The calling operation will be resumed (or errored) once call is completed.
call()
is a uniform integration point for calling async functions,
generator functions, and plain functions.
To call an async function:
Examples
Example 1
Example 1
async function* googleSlowly() {
return yield* call(async function() {
await new Promise(resolve => setTimeout(resolve, 2000));
return await fetch("https://google.com");
});
}
or a plain function:
Example 2
Example 2
yield* call(() => "a string");