Class ThreadJob<WorkerData, ResultType>

A thread job.

Type Parameters

Implements

Constructors

Properties

completedSubject: BehaviorSubject<boolean> = ...

A subject that contains whether or not the job was completed.

error?: Error

The error that the job failed with.

id: string

A unique identifier of the job. This differs from the threadId, which is created by the os and set when the thread actually starts..

onCancel?: () => void

What should happen when the thread job was cancelled.

onComplete?: () => void

What should happen when the thread job completes.

onError?: (error: Error) => void

What should happen when an error occurs inside the thread job.

onMessage?: (message: unknown) => void

What should happen when a message is received from the thread job.

priority: boolean

Wether or not the job should use priority workers.

false
progress: Percentage

The progress of the job in a percentage.

queuedAtMs: number

Timestamp of when the job was queued in milliseconds.

result?: ResultType

The result that the job finished with.

startedAtMs?: number

Timestamp of when the job was started in milliseconds.

The status of the job.

stoppedAtMs?: number

Timestamp of when the job was stopped in milliseconds.

threadId?: number

The id of the thread that the job is running in. Set by the os.

timeout: number

The timeout after which the job should exit with an error.

one hour in ms.
type: "function" | "job"

The type of the job. (whether it's a real job with db persistence or just a simple function call).

workerData: WorkerData

Data that should be passed to the worker.