-
Notifications
You must be signed in to change notification settings - Fork 0
Task Options
Eric McGary edited this page Feb 1, 2013
·
9 revisions
Check out the live docs for the most up to date functionality until then.
var task = new Task({ name:"task", id:"id", concurrent:true, type:MonkeyBars.TaskTypes.Simple, logLevel:MonkeyBars.LogLevels.Verbose, worker:{ constructor:EXTENDED_WORKER_TASK_CONSTRUCTOR, handler:function(e){ ... } }, tasks:[...], count:3, max:2, interval:1000, when:function(){ ... }, while:function(){ ... }, timeout:1000, onChange:function(state, product, error){ ... }, onStart:function(){ ... }, onFault:function(error){ ... }, onComplete:function(){ ... }, onCancel:function(){ ... }, performTask:function(){ ... } });
Name | Type | Required | Default | Used With | Description |
---|---|---|---|---|---|
name | String | NO | undefined | T,P,S | User Defined name for the task. Used in task look up and logging. |
id | String | NO | undefined | T,P,S | User Defined identifier for the task. Used in task look up and logging. |
concurrent | Boolean | NO | false | T,P,S | Whether or not to run the task concurrently through Web Workers. |
type | String | NO | options | T,P,S | The kind of task (MonkeyBars.TaskTypes). |
logLevel | Integer | NO | 0 | T,P,S | The default logging level for tasks (MonkeyBars.LogLevels). |
tasks | Array | NO | undefined | P,S | An Array of sub tasks of the task. |
worker | Object | NO | undefined | T | An object containing an extended WorkerTask's constructor as well as handler functionality for when a postMessage is recieved from a parallel thread. |
max | Integer | NO | undefined | P | The maximum amount of tasks that can be run simultaniously on a parallel task type. |
Name | Type | Required | Default | Used With | Description |
---|---|---|---|---|---|
count | Integer | NO | 1 | T,P,S | Used with the for decorator. The number of times a task will perform until calling complete. |
interval | Integer | NO | 0 | T,P,S | Interval is used in conjunction with all three of the decorators. It is amount of time in millisecods before the associated method or task will be called. |
when | Function | NO | undefined | T,P,S | Method used with the when decorator. This method will be called on an interval and when it returns true the task will execute. |
while | Function | NO | undefined | T,P,S | Method used with while decorator. The task will itteratively run until this method returns false. |
Name | Type | Required | Default | Used With | Description |
---|---|---|---|---|---|
timeout | Integer | NO | 0 | T,P,S | Time in milliseconds in which a task will time out and throw a fault. |
onChange | Function | NO | empty | T,P,S | This method is called during the execution lifecycle of the task. It is intentionally left blank and is up to the instance to describe it functionality. |
onStart | Function | NO | empty | T,P,S | Convenience method called when the task starts. |
onFault | Function | NO | empty | T,P,S | Convenience method called when the task faults. |
onComplete | Function | NO | empty | T,P,S | Convenience method called when the task completes. |
onCancel | Function | NO | empty | T,P,S | Convenience method called when the task is canceled. |
performTask | Function | YES (T) | empty | T,P,S | This method is required for simple tasks and will throw an exception if it is called and not overridden. If you overwrite this method on a task group then you need to make sure that you call the extended/implemented classes original prototype method. |
\* *The example above is sudo code, it will not actually function as written.*
\* *T (Task/SimpleTask), P (ParallelTask), S (SequenceTask)*