Type alias GroupSubTasksT<T, R>

GroupSubTasksT<T, R>: ArrayWithMinOneOrTwoElementsT<Task<T, R> | GroupTask<T, R>>

The type of group sub tasks.

Type Parameters

  • T extends unknown[]

    The type of the task worker parameters.

  • R

    The type of the task worker result.

Example

Use to define group sub tasks.

const subTasks: GroupSubTasksT<[number, number], number> = [
new Task({
worker: (a, b) => a + b,
}),
// task result type must be defined for a task to match with that of
// group sub tasks array, else use unknown or any in group sub tasks
// array
new Task<[number, number], number>({
workerParams: [1, 2],
}),
new Task({
worker: (a, b) => a * b,
workerParams: [3, 4],
}),
];

Example

Use to create template for similar group sub tasks.

type TwoNumbersSubTaskTemplate = GroupSubTasksT<[number, number], number>;
const calcTasks1: TwoNumbersSubTaskTemplate = [
new Task({ worker: (a, b) => a + b }),
new Task({ worker: (a, b) => a - b }),
];
const calcTasks2: TwoNumbersSubTaskTemplate = [
new Task({ worker: (a, b) => a * b }),
new Task({ worker: (a, b) => a / b }),
];

Generated using TypeDoc