Class Task
Defined in: | src/lib/taskgroup.coffee |
Inherits: | Interface |
Overview
Examples:
task = require('taskgroup').Task.create('my synchronous task', function(){
return 5
}).done(console.log) // [null, 5]
task = require('taskgroup').Task.create('my asynchronous task', function(complete){
complete(null, 5)
}).done(console.log) // [null, 5]
task = require('taskgroup').Task.create('my task that errors', function(){
var err = new Error('deliberate error')
return err; // if asynchronous, can also do: complete(err)
// thrown and uncaught errors are also caught thanks to domains, but that should be avoided
// as it would put your app in an unknown state
}).done(console.log) // [Error('deliberator error')]
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
Task .create(args...) Source
Constructor Details
::constructor(args...) Source
Instance Method Details
::destroy() Source
Boolean ::hasExited() Source
Boolean ::hasStarted() Source
Boolean ::isComplete() Source
Boolean ::isDestroyed() Source
::onceDone(listener) Source
::run() Source
::setConfig(opts = {}) Source