Class Task
Defined in: | src/lib/taskgroup.coffee |
Inherits: | Interface |
Overview
Our Task Class.
Available configuration is documented in ::setConfig.
Available events:
started()
- emitted when we start executionrunning()
- emitted when the method starts executionfailed(err)
- emitted when execution exited with a failurepassed()
- emitted when execution exited with a successcompleted(err, args...)
- emitted when execution exited,args
are the result arguments from the methoderror(err)
- emtited if an unexpected error occurs without ourselfdone(err, args...)
- emitted when either execution completes (thecompleted
event) or when an unexpected error occurs (theerror
event)
Available internal statuses:
null
- execution has not yet started'started'
- execution has begun'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
Examples:
Class Method Summary
- Task .create(args...) Creates a new Task instance.
- Boolean .isTask(item) A helper method to check if the passed argument is an instanceof a Task.
Instance Method Summary
- ::constructor(args...) Initialize our new Task instance.
- ::destroy() Destroy the task and prevent it from executing ever again.
- Boolean ::hasExited() Have we finished its execution yet?
- Boolean ::hasStarted() Have we started execution yet?
- Boolean ::isComplete() Have we completed its execution yet?
- Boolean ::isDestroyed() Have we been destroyed?
- ::onceDone(listener) Once Done Promise.
- ::run() Start the execution of the task.
- ::setConfig(opts = {}) Set the configuration for our instance.
- ::whenDone(listener) When Done Promise.
Inherited Method Summary
Methods inherited from Interface
.whenDone, .onceDone, .done, .getNames, .getName, .getConfig
Class Method Details
Constructor Details
::constructor(args...) Source
Initialize our new Task instance. Forwards arguments onto ::setConfig.
Instance Method Details
::destroy() Source
Destroy the task and prevent it from executing ever again.
Boolean ::hasExited() Source
Have we finished its execution yet?
Boolean ::hasStarted() Source
Have we started execution yet?
Boolean ::isComplete() Source
Have we completed its execution yet?
Boolean ::isDestroyed() Source
Have we been destroyed?
::onceDone(listener) Source
Once Done Promise. Fires the listener once, either on the next tick if we are already done, or if not, once the done
event fires.
::run() Source
Start the execution of the task.
Will emit an error
event if the task has already started before.
::setConfig(opts = {}) Source
::whenDone(listener) Source
When Done Promise. Fires the listener, either on the next tick if we are already done, or if not, each time the done
event fires.