Skip to content

Documentation / @hybrid-compute/worker / WorkerTaskType

Type Alias: WorkerTaskType<Input, Output> ​

ts
type WorkerTaskType<Input, Output> = (
  input: Input,
  context: Required<TaskContextInterface>
) => Output | Promise<Output>;

Defined in: packages/worker/src/types.ts:96

A task in the worker script, for exposeTasks. It gets the input and a context with a signal, which aborts when the caller cancels the task or its timeout passes.

Type Parameters ​

Input ​

Input = never

The input type of the task.

Output ​

Output = unknown

The output type of the task.

Parameters ​

input ​

Input

context ​

Required<TaskContextInterface>

Returns ​

| Output | Promise<Output>