Class: TaskGroup

TaskGroup()

new TaskGroup()

"Task Groups" provide a means for applying task modifiers to groups of tasks. Once a Task is declared as part of a group task, modifiers like drop or restartable will no longer affect the individual Task. Instead those modifiers can be applied to the entire group.

Turns the decorated property into a task group.

Optionally takes a hash of options that will be applied as modifiers to the task group. For instance maxConcurrency or keepLatest.

import Component from '@glimmer/component';
import { task, taskGroup } from 'ember-concurrency';

class MyComponent extends Component {
  @taskGroup({ maxConcurrency: 5 }) chores;

  @task({ group: 'chores' })
  *mowLawn() {}

  @task({ group: 'chores' })
  *doDishes() {}
}
Source:

Members

(readonly) isIdle :boolean

true if the task is not in the running or queued state.

Type:
  • boolean
Source:

(readonly) isQueued :boolean

true if any future task instances are queued.

Type:
  • boolean
Source:

(readonly) isRunning :boolean

true if any current task instances are running.

Type:
  • boolean
Source:

(readonly) last :TaskInstance

The most recently started task instance.

Type:
Source:

(readonly) lastCanceled :TaskInstance

The most recently canceled task instance.

Type:
Source:

(readonly) lastComplete :TaskInstance

The most recently completed task instance.

Type:
Source:

(readonly) lastErrored :TaskInstance

The most recent task instance that errored.

Type:
Source:

(readonly) lastIncomplete :TaskInstance

The most recent task instance that is incomplete.

Type:
Source:

(readonly) lastPerformed :TaskInstance

The most recently performed task instance.

Type:
Source:

(readonly) lastRunning :TaskInstance

The most recent task instance that is currently running.

Type:
Source:

(readonly) lastSuccessful :TaskInstance

The most recent task instance that succeeded.

Type:
Source:

(readonly) performCount :number

The number of times this task has been performed.

Type:
  • number
Source:

(readonly) state :string

The current state of the task: "running", "queued" or "idle".

Type:
  • string
Source:

Methods

(async) cancelAll()

Cancels all running or queued TaskInstances for this task group. If you're trying to cancel a specific TaskInstance (rather than all of the instances running under this task group) call .cancel() on the specific TaskInstance.

Parameters:
Name Type Description
options.reason

A descriptive reason the task group was cancelled. Defaults to ".cancelAll() was explicitly called on the Task".

options.resetState

If true, will clear the task group state (last* and performCount properties will be set to initial values). Defaults to false.

Source: