Skip to main content
Version: 0.17

Class: TaskQueue<Type, Data, Options, Result>

TaskQueue is a FIFO queue of asynchronous tasks that should be performed sequentially.

Tasks are added to the queue with push. Each task will be processed by calling its process method.

By default, task queues will be processed automatically, as soon as tasks are pushed to them. This can be overridden by setting the autoProcess setting to false and calling process when you'd like to start processing.

Type parameters​

NameType
Typestring
Dataunknown
Optionsunknown
Resultunknown

Hierarchy​

Constructors​

constructor​

• new TaskQueue<Type, Data, Options, Result>(target, settings?)

Creates an instance of TaskQueue.

Type parameters​

NameType
Typestring
Dataunknown
Optionsunknown
Resultunknown

Parameters​

NameType
targetPerformer<Type, Data, Options, Result>
settingsTaskQueueSettings<Type, Data, Options>

Inherited from​

Evented.constructor

Defined in​

packages/@orbit/core/src/task-queue.ts:83

Properties​

autoProcess​

• autoProcess: boolean

Defined in​

packages/@orbit/core/src/task-queue.ts:67

Accessors​

bucket​

• get bucket(): undefined | Bucket<Task<Type, Data, unknown>[]>

A bucket used to persist the state of this queue.

Returns​

undefined | Bucket<Task<Type, Data, unknown>[]>

Defined in​

packages/@orbit/core/src/task-queue.ts:132


current​

• get current(): Task<Type, Data, unknown>

The current task being processed (if actively processing), or the next task to be processed (if not actively processing).

Returns​

Task<Type, Data, unknown>

Defined in​

packages/@orbit/core/src/task-queue.ts:154


currentProcessor​

• get currentProcessor(): TaskProcessor<Type, Data, Options, Result>

The processor wrapper that is processing the current task (or next task, if none are being processed).

Returns​

TaskProcessor<Type, Data, Options, Result>

Defined in​

packages/@orbit/core/src/task-queue.ts:162


empty​

• get empty(): boolean

Is the queue empty?

Returns​

boolean

Defined in​

packages/@orbit/core/src/task-queue.ts:178


entries​

• get entries(): Task<Type, Data, unknown>[]

The tasks in the queue.

Returns​

Task<Type, Data, unknown>[]

Defined in​

packages/@orbit/core/src/task-queue.ts:146


error​

• get error(): undefined | Error

If an error occurs while processing a task, processing will be halted, the fail event will be emitted, and this property will reflect the error encountered.

Returns​

undefined | Error

Defined in​

packages/@orbit/core/src/task-queue.ts:171


length​

• get length(): number

The number of tasks in the queue.

Returns​

number

Defined in​

packages/@orbit/core/src/task-queue.ts:139


name​

• get name(): undefined | string

Name used for tracking / debugging this queue.

Returns​

undefined | string

Defined in​

packages/@orbit/core/src/task-queue.ts:118


performer​

• get performer(): Performer<Type, Data, Options, Result>

The object which will perform the tasks in this queue.

Returns​

Performer<Type, Data, Options, Result>

Defined in​

packages/@orbit/core/src/task-queue.ts:125


processing​

• get processing(): boolean

Is the queue actively processing a task?

Returns​

boolean

Defined in​

packages/@orbit/core/src/task-queue.ts:185


reified​

• get reified(): Promise<void>

Resolves when the queue has been fully reified from its associated bucket, if applicable.

Returns​

Promise<void>

Defined in​

packages/@orbit/core/src/task-queue.ts:195

Methods​

activate​

â–¸ activate(): Promise<void>

Returns​

Promise<void>

Defined in​

packages/@orbit/core/src/task-queue.ts:107


clear​

â–¸ clear(e?): Promise<void>

Cancels the current task and completely clears the queue.

Parameters​

NameType
e?Error

Returns​

Promise<void>

Defined in​

packages/@orbit/core/src/task-queue.ts:258


emit​

â–¸ emit(event, ...args): void

Parameters​

NameType
eventEvent
...argsunknown[]

Returns​

void

Inherited from​

Evented.emit

Defined in​

packages/@orbit/core/src/evented.ts:29


listeners​

â–¸ listeners(event): Listener[]

Parameters​

NameType
eventEvent

Returns​

Listener[]

Inherited from​

Evented.listeners

Defined in​

packages/@orbit/core/src/evented.ts:30


off​

â–¸ off(event, listener?): void

Parameters​

NameType
eventEvent
listener?Listener

Returns​

void

Inherited from​

Evented.off

Defined in​

packages/@orbit/core/src/evented.ts:27


on​

â–¸ on(event, listener): () => void

Parameters​

NameType
eventEvent
listenerListener

Returns​

fn

â–¸ (): void

Returns​

void

Inherited from​

Evented.on

Defined in​

packages/@orbit/core/src/evented.ts:26


one​

â–¸ one(event, listener): () => void

Parameters​

NameType
eventEvent
listenerListener

Returns​

fn

â–¸ (): void

Returns​

void

Inherited from​

Evented.one

Defined in​

packages/@orbit/core/src/evented.ts:28


process​

â–¸ process(): Promise<void>

Processes all the tasks in the queue. Resolves when the queue is empty.

Returns​

Promise<void>

Defined in​

packages/@orbit/core/src/task-queue.ts:321


push​

â–¸ push(task): Promise<Result>

Push a new task onto the end of the queue.

If autoProcess is enabled, this will automatically trigger processing of the queue.

Returns the result of processing the pushed task.

Parameters​

NameType
taskTask<Type, Data, Options>

Returns​

Promise<Result>

Defined in​

packages/@orbit/core/src/task-queue.ts:207


retry​

â–¸ retry(): Promise<Result>

Cancels and re-tries processing the current task.

Returns the result of the retried task.

Returns​

Promise<Result>

Defined in​

packages/@orbit/core/src/task-queue.ts:223


shift​

â–¸ shift(e?): Promise<undefined | Task<Type, Data, unknown>>

Cancels the current task and removes it, but does not continue processing.

Returns the canceled and removed task.

Parameters​

NameType
e?Error

Returns​

Promise<undefined | Task<Type, Data, unknown>>

Defined in​

packages/@orbit/core/src/task-queue.ts:280


skip​

â–¸ skip(e?): Promise<void>

Cancels and discards the current task.

If autoProcess is enabled, this will automatically trigger processing of the queue.

Parameters​

NameType
e?Error

Returns​

Promise<void>

Defined in​

packages/@orbit/core/src/task-queue.ts:240


unshift​

â–¸ unshift(task): Promise<Result>

Cancels processing the current task and inserts a new task at the beginning of the queue. This new task will be processed next.

Returns the result of processing the new task.

Parameters​

NameType
taskTask<Type, Data, Options>

Returns​

Promise<Result>

Defined in​

packages/@orbit/core/src/task-queue.ts:303