import { workerTask } from "https://deno.land/x/simple_utility@v2.3.1/src/pure/worker.ts";
Register TaskAction
and return reusable task execution context.
Worker
instance is created and destroyed each time they run TaskContext
.
import
can only use "syntax", not "declaration".
Examples
Example 1
Example 1
const task = workerTask<number, number>(async (data) => {
const {delay} = await import("https://deno.land/std/async/mod.ts");
await delay(data);
return {
message: data * 2
};
});
const result1 = await task(10);
const result2 = await task(20);
Parameters
task: TaskAction<T, K>