Skip to content

workloads / main / Task

Class: Task<P> ​

Extends ​

Type Parameters ​

Type Parameter

P

Constructors ​

new Task() ​

ts
new Task<P>(
   name, 
   work, 
options?): Task<P>

Parameters ​

ParameterTypeDescription

name

string

Name of the task.

work

(task) => Promise<void>

Function that processes a task.

options?

TaskOptions<P>

‐

Returns ​

Task<P>

Overrides ​

Workload.constructor

Methods ​

handleError() ​

ts
handleError(
   error?, 
   data?, 
   executionId?): void

Parameters ​

ParameterType

error?

unknown

data?

P

executionId?

string

Returns ​

void


performLater() ​

ts
performLater(data, options?): Promise<ExecutionId | ExecutionId[]>

Performs the task later, dispatching the task to a queue.

NOTES

In development, the task will be performed immediately.

In test, the task will collected ans can be retrieved with the performedTasks test helper.

Parameters ​

ParameterType

data

P | P[]

options?

PerformOptions

Returns ​

Promise<ExecutionId | ExecutionId[]>


performNow() ​

ts
performNow(data): Promise<void>

Performs the task immediately in the current processs.

Parameters ​

ParameterType

data

P | P[]

Returns ​

Promise<void>

Properties ​

PropertyModifierTypeDescription
idreadonlystringUnique ID
namepublicstringName of the task.
options?publicTaskOptions<P>-
workpublic(task: object) => Promise<void>Function that processes a task.