Type alias TaskWorkerT<T, R>

TaskWorkerT<T, R>: ((...workerParams) => R) | undefined

The type of the task worker function.

Type Parameters

  • T extends unknown[]

    The type of the task worker parameters.

  • R

    The type of the task worker result.

Type declaration

    • (...workerParams): R
    • Parameters

      • Rest ...workerParams: T

      Returns R

Example

Use to define a task worker function.

const moviesGetter: TaskWorkerT<[url: string], Promise<JSON>> = async (url) => {
const response = await fetch(url);
const movies = await response.json();
return movies;
};

Example

Use to create a template for similar task worker functions.

type TwoNumbersWorkerTemplate = TaskWorkerT<[number, number], number>;
const adder: TwoNumbersWorkerTemplate = (a, b) => a + b;
const multiplier: TwoNumbersWorkerTemplate = (a, b) => a * b;

Generated using TypeDoc