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.

import { task, taskGroup } from 'ember-concurrency';

export default Controller.extend({
  chores: taskGroup().drop(),

  mowLawn:       task(taskFn).group('chores'),
  doDishes:      task(taskFn).group('chores'),
  changeDiapers: task(taskFn).group('chores')
});
Source:

Members

(readonly) isIdle :boolean

true if the task group 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 group has been performed.

Type:
  • number
Source:

(readonly) state :string

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

Type:
  • string
Source:

Methods

cancelAll(optionsopt)

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 Attributes Description
options Object <optional>
Properties
Name Type Attributes Default Description
reason string <optional>
.cancelAll() was explicitly called on the Task

a descriptive reason the task group was cancelled

resetState boolean <optional>

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

Source: