Base class containing common functionality for Task and TaskGroup.

BaseInterface()

Extends EventEmitter

Static Members
create (args)
Instance Members
constructor ()
whenDone (listener)
onceDone (listener)
done (listener)
names
name

Our TaskGroup class.

Available configuration is documented in TaskGroup#setConfig.

Available events:

  • pending() - emitted when execution has been triggered
  • running() - emitted when the first item starts execution
  • failed(error) - emitted when execution exited with a failure
  • passed() - emitted when execution exited with a success
  • completed(error, result) - emitted when execution exited, result is an {?Array} of the result arguments for each item that executed
  • error(error) - emtited if an unexpected error occured within ourself
  • done(error, result) - emitted when either the execution completes (the completed event) or when an unexpected error occurs (the error event)
  • item.*(...) - bubbled events from an added item
  • task.*(...) - bubbled events from an added {Task}
  • group.*(...) - bubbled events from an added {TaskGroup}

Available internal statuses:

  • 'created' - execution has not yet started
  • 'pending' - execution has been triggered
  • 'running' - execution of items has begun
  • 'failed' - execution has exited with failure status
  • 'passed' - execution has exited with success status
  • 'destroyed' - we've been destroyed and can no longer execute
TaskGroup()

Extends BaseInterface

Static Members
isTaskGroup (group)
Instance Members
type
Task
TaskGroup
events
storeResult
error
status
result
totalItems
itemTotals
hasRemaining
hasRunning
hasItems
hasError
hasResult
hasSlots
shouldFire
shouldPause
paused
empty
exited
started
completed
resetResult ()
clearRemaining ()
clearRunning ()
constructor (args)
autoRun ()
setConfig ([config], args)
setNestedTaskConfig (opts)
setNestedTaskGroupConfig (opts)
addMethod (method, [opts])
addItem (item, args)
addItems (items, args)
createTask (args)
addTask (args)
addTasks (items, args)
createTaskGroup (args)
addTaskGroup (args)
addTaskGroups (items, args)
fireNextItems ()
fireNextItem ()
itemDoneCallback (item, args)
finish ()
abort ()
destroy ()
fire ()
run ()

Our Task Class

Available configuration is documented in Task#setConfig.

Available events:

  • pending() - emitted when execution has been triggered
  • running() - emitted when the method starts execution
  • failed(error) - emitted when execution exited with a failure
  • passed() - emitted when execution exited with a success
  • completed(error, ...resultArguments) - emitted when execution exited, resultArguments are the result arguments from the method
  • error(error) - emtited if an unexpected error occurs without ourself
  • done(error, ...resultArguments) - emitted when either execution completes (the completed event) or when an unexpected error occurs (the error event)

Available internal statuses:

  • 'created' - execution has not yet started
  • 'pending' - execution has been triggered
  • 'running' - execution of our method has begun
  • 'failed' - execution of our method has failed
  • 'passed' - execution of our method has succeeded
  • 'destroyed' - we've been destroyed and can no longer execute
Task()

Extends BaseInterface

Example
const Task = require('taskgroup').Task

Task.create('my synchronous task', function () {
return 5
}).done(console.info).run()  // [null, 5]

Task.create('my asynchronous task', function (complete) {
complete(null, 5)
}).done(console.info).run()  // [null, 5]

Task.create('my task that returns an error', function () {
var error = new Error('deliberate error')
return error
}).done(console.info).run()  // [Error('deliberator error')]

Task.create('my task that passes an error', function (complete) {
var error = new Error('deliberate error')
complete(error)
}).done(console.info).run()  // [Error('deliberator error')]
Static Members
isTask (item)
Instance Members
type
events
storeResult
error
status
result
started
exited
completed
resetResult ()
clearDomain ()
constructor (args)
setConfig ([config], args)
itemCompletionCallback (args)
abort ()
finish ()
destroy ()
fire ()
run ()