Package | com.rosettastone.library.taskmanager |
Class | public class Task |
Inheritance | Task ![]() |
Implements | ITask |
Subclasses | AbstractCompositeTask, AbstractTaskManager, InterruptibleTask, ObserverTask, StubTask, SynchronousTask, TaskWithClosure |
Property | Defined By | ||
---|---|---|---|
data : * [read-only]
Optional data parameter passed to the Task complete/error/interruption method. | Task | ||
id : Number [read-only]
| Task | ||
interruptible : Boolean [read-only]
The current Task can be interrupted. | Task | ||
interruptingTask : ITask [read-only]
The Task currently interrupting the composite Task's execution (or NULL if no such Task exists). | Task | ||
isComplete : Boolean [read-only]
The current task has successfully completed execution. | Task | ||
isErrored : Boolean [read-only]
The current task failed. | Task | ||
isInterrupted : Boolean [read-only]
| Task | ||
isRunning : Boolean [read-only]
The task is currently running. | Task | ||
message : String [read-only]
Optional message parameter passed to the task complete/error/interruption method. | Task | ||
numInternalOperations : int [read-only]
Number of internal operations conducted by this task. | Task | ||
numInternalOperationsCompleted : int [read-only]
Number of internal operations that have completed. | Task | ||
numInternalOperationsPending : int [read-only]
Number of internal operations not yet completed. | Task | ||
numTimesCompleted : int [read-only]
Number of times this task has completed. | Task | ||
numTimesErrored : int [read-only]
Number of times this task has errored. | Task | ||
numTimesInterrupted : int [read-only]
Number of times this task has been interrupted. | Task | ||
numTimesReset : int [read-only]
Number of times this task has been reset. | Task | ||
numTimesStarted : int [read-only]
Number of times this task has been started. | Task | ||
running : Boolean [read-only]
The task is currently running. | Task | ||
synchronous : Boolean [read-only]
The current task can be executed synchronously. | Task | ||
taskIdentifier : String
(Optional) human-readable label for task. | Task | ||
uniqueID : Number [read-only]
Unique ID for a task. | Task |
Property | Defined By | ||
---|---|---|---|
logger : ILogger [read-only]
Instance of ILogger to be used for any custom Task logging. | Task |
Method | Defined By | ||
---|---|---|---|
Task(taskIdentifier:String = null)
Constructor
| Task | ||
Executes the specified tasks when the current task is executed. | Task | ||
Task | |||
interrupt():Boolean
Interruptible tasks should override interrupt() and get interruptible() if they are interruptible. | Task | ||
interruptForTask(interruptingTask:ITask):Boolean
Interrupts the current Task to wait on the Task specified. | Task | ||
Executes the specified tasks if the current task fails. | Task | ||
reset():void
Resets the task to it's pre-run state. | Task | ||
Starts a task. | Task | ||
Executes the specified tasks once the current task has completed successfully. | Task | ||
withCompleteHandler(completeHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate completion, this method may also be used for notification purposes. | Task | ||
withErrorHandler(errorHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate failure, this method may also be used for notification purposes. | Task | ||
withFinalHandler(finalHandler:Function):ITask
This handler is invoked upon either success or failure of the Task. | Task | ||
withInterruptionHandler(interruptionHandler:Function):ITask | Task | ||
withStartedHandler(startedHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate starting, this method may also be used for notification purposes. | Task |
Method | Defined By | ||
---|---|---|---|
customReset():void
Override this method to perform any custom reset operations. | Task | ||
customRun():void
Override this method to give your Task functionality. | Task | ||
dispatchProgressEvent():void | Task | ||
getLoggerString(string:String):String
Returns a string for logging the specified task-state event. | Task | ||
taskComplete(message:String, data:* = null):void
This method should be called upon Task completion. | Task | ||
taskError(message:String, data:* = null):void
This method should be called upon Task failure. | Task | ||
taskInterrupted(message:String, data:* = null):void
Call this method to interrupt the currently running Task. | Task | ||
throwErrorIfAnyObjectInArrayIsNotATask(tasks:Array):void | Task |
Event | Summary | Defined By | ||
---|---|---|---|---|
Task | ||||
Task | ||||
Task | ||||
Task | ||||
Task | ||||
Task |
_complete | property |
TaskPrivateNamespace var _complete:Boolean = false
_completeHandlers | property |
TaskPrivateNamespace var _completeHandlers:Array
_data | property |
TaskPrivateNamespace var _data:*
_errored | property |
TaskPrivateNamespace var _errored:Boolean
_errorHandlers | property |
TaskPrivateNamespace var _errorHandlers:Array
_finalHandlers | property |
TaskPrivateNamespace var _finalHandlers:Array
_interrupted | property |
TaskPrivateNamespace var _interrupted:Boolean
_interruptingTask | property |
TaskPrivateNamespace var _interruptingTask:ITask
_interruptionHandlers | property |
TaskPrivateNamespace var _interruptionHandlers:Array
_logger | property |
TaskPrivateNamespace var _logger:ILogger
_message | property |
TaskPrivateNamespace var _message:String
_numTimesCompleted | property |
TaskPrivateNamespace var _numTimesCompleted:int
_numTimesErrored | property |
TaskPrivateNamespace var _numTimesErrored:int
_numTimesInterrupted | property |
TaskPrivateNamespace var _numTimesInterrupted:int
_numTimesReset | property |
TaskPrivateNamespace var _numTimesReset:int
_numTimesStarted | property |
TaskPrivateNamespace var _numTimesStarted:int
_running | property |
TaskPrivateNamespace var _running:Boolean = false
_startedHandlers | property |
TaskPrivateNamespace var _startedHandlers:Array
_taskHasBeenRunAtLeastOnce | property |
TaskPrivateNamespace var _taskHasBeenRunAtLeastOnce:Boolean
_taskIdentifier | property |
TaskPrivateNamespace var _taskIdentifier:String
_uniqueID | property |
TaskPrivateNamespace var _uniqueID:Number
data | property |
data:*
[read-only] Optional data parameter passed to the Task complete/error/interruption method.
public function get data():*
id | property |
id:Number
[read-only]
public function get id():Number
ID | property |
TaskPrivateNamespace static var ID:Number = 0
interruptible | property |
interruptible:Boolean
[read-only] The current Task can be interrupted. Invoking interrupt() for a Task that is not marked as interruptible may result in an error.
public function get interruptible():Boolean
interruptingTask | property |
interruptingTask:ITask
[read-only] The Task currently interrupting the composite Task's execution (or NULL if no such Task exists).
public function get interruptingTask():ITask
isComplete | property |
isComplete:Boolean
[read-only] The current task has successfully completed execution.
public function get isComplete():Boolean
isErrored | property |
isErrored:Boolean
[read-only] The current task failed.
public function get isErrored():Boolean
isInterrupted | property |
isInterrupted:Boolean
[read-only]
public function get isInterrupted():Boolean
isRunning | property |
isRunning:Boolean
[read-only] The task is currently running. This value is FALSE if the task has not been run, has completed run (succesfully or due to a failure), or has been interrupted.
public function get isRunning():Boolean
logger | property |
logger:ILogger
[read-only] Instance of ILogger to be used for any custom Task logging.
protected function get logger():ILogger
message | property |
message:String
[read-only] Optional message parameter passed to the task complete/error/interruption method.
public function get message():String
numInternalOperations | property |
numInternalOperations:int
[read-only] Number of internal operations conducted by this task. Sub-classes should override this method if containing a value > 1; If value > 1, task should dispatch ProgressEvent.PROGRESS events manually to indicate changes in numInternalOperationsCompleted. If value == 1, task will automatically dispatching ProgressEvent.PROGRESS events.
public function get numInternalOperations():int
numInternalOperationsCompleted | property |
numInternalOperationsCompleted:int
[read-only] Number of internal operations that have completed. Sub-classes should override this method if containing a value > 1;
public function get numInternalOperationsCompleted():int
numInternalOperationsPending | property |
numInternalOperationsPending:int
[read-only] Number of internal operations not yet completed.
public function get numInternalOperationsPending():int
numTimesCompleted | property |
numTimesCompleted:int
[read-only] Number of times this task has completed.
public function get numTimesCompleted():int
numTimesErrored | property |
numTimesErrored:int
[read-only] Number of times this task has errored.
public function get numTimesErrored():int
numTimesInterrupted | property |
numTimesInterrupted:int
[read-only] Number of times this task has been interrupted.
public function get numTimesInterrupted():int
numTimesReset | property |
numTimesReset:int
[read-only] Number of times this task has been reset. This is the only counter that is not reset by the reset() method.
public function get numTimesReset():int
numTimesStarted | property |
numTimesStarted:int
[read-only] Number of times this task has been started.
public function get numTimesStarted():int
running | property |
running:Boolean
[read-only] The task is currently running. This value is FALSE if the task has not been run, has completed run (succesfully or due to a failure), or has been interrupted.
public function get running():Boolean
synchronous | property |
synchronous:Boolean
[read-only] The current task can be executed synchronously.
public function get synchronous():Boolean
taskIdentifier | property |
taskIdentifier:String
(Optional) human-readable label for task.
public function get taskIdentifier():String
public function set taskIdentifier(value:String):void
uniqueID | property |
uniqueID:Number
[read-only] Unique ID for a task.
public function get uniqueID():Number
Task | () | Constructor |
public function Task(taskIdentifier:String = null)
Constructor
ParameterstaskIdentifier:String (default = null ) — Human-friendly ID string useful for debugging purposes only.
|
and | () | method |
public function and(... chainedTasks):ITask
Executes the specified tasks when the current task is executed. If the current task has already been started the new tasks will be executed immediately. Failures or interruptions in the current task will not affect the chained tasks.
Parameters
... chainedTasks — One or more tasks
|
ITask |
customReset | () | method |
protected function customReset():void
Override this method to perform any custom reset operations.
customRun | () | method |
protected function customRun():void
Override this method to give your Task functionality.
disconnectFromInterruptingTask | () | method |
public function disconnectFromInterruptingTask():void
dispatchProgressEvent | () | method |
protected function dispatchProgressEvent():void
doTaskComplete | () | method |
TaskPrivateNamespace function doTaskComplete(message:String, data:* = null):void
Parameters
message:String | |
data:* (default = null )
|
doTaskError | () | method |
TaskPrivateNamespace function doTaskError(message:String, data:* = null):void
Parameters
message:String | |
data:* (default = null )
|
doTaskInterrupted | () | method |
TaskPrivateNamespace function doTaskInterrupted(message:String, data:* = null):void
Parameters
message:String | |
data:* (default = null )
|
getLoggerString | () | method |
protected function getLoggerString(string:String):String
Returns a string for logging the specified task-state event.
Parameters
string:String — String to append to log
|
String |
interrupt | () | method |
public function interrupt():Boolean
Interruptible tasks should override interrupt() and get interruptible() if they are interruptible. If they are, they should fire a TaskEvent.INTERRUPTED to indicate successful interruption of the task. If the interrupting fails at runtime, this method returns false
ReturnsBoolean |
interruptForTask | () | method |
public function interruptForTask(interruptingTask:ITask):Boolean
Interrupts the current Task to wait on the Task specified. Once this Task dispatches a TaskEvent.COMPLETE event, this Task will resume. If the specified Task dispatches a TaskEvent.ERROR event this Task will also error. TaskEvent.INTERRUPTED events are ignored. If this method is called once with a Task and then called again before that Task has completed, Event listeners will be removed from the first Task and added to the second one. There can only be 1 active interrupting Task at a time. If this Task should be interrupted by more than one Task, a CompositeTask or ObserverTask should be used. If the specified interrupting Task is already running this method will simply add event listeners. If it is not running this method will add event listeners but will rely on external code to run the interrupter.
Parameters
interruptingTask:ITask — Task
|
Boolean |
onInterruptingTaskComplete | () | method |
TaskPrivateNamespace function onInterruptingTaskComplete(event:TaskEvent):void
Parameters
event:TaskEvent |
onInterruptingTaskError | () | method |
TaskPrivateNamespace function onInterruptingTaskError(event:TaskEvent):void
Parameters
event:TaskEvent |
or | () | method |
public function or(... chainedTasks):ITask
Executes the specified tasks if the current task fails.
Parameters
... chainedTasks — One or more tasks
|
ITask |
reset | () | method |
public function reset():void
Resets the task to it's pre-run state. This allows it to be re-run. This method can only be called on non-running tasks.
run | () | method |
public final function run():ITask
Starts a task. This method will dispatch a TaskEvent.STARTED to indicate that the task has begun. This method may also be used to retry/resume an errored task.
ReturnsITask |
taskComplete | () | method |
protected function taskComplete(message:String, data:* = null):void
This method should be called upon Task completion. It dispatches a TaskEvent.COMPLETE event and toggles the Tasks's "running" and "complete" states. It also invokes the success handler if one has been provided.
Parameters
message:String — An (optional) message or data in string form
| |
data:* (default = null ) — Optional data object related to the Task dispatching this event.
|
taskError | () | method |
protected function taskError(message:String, data:* = null):void
This method should be called upon Task failure. It dispatches a TaskEvent.ERROR event and toggles the Tasks's "running" and "complete" states. It also invokes the error handler if one has been provided.
Parameters
message:String — An (optional) reason for the error
| |
data:* (default = null ) — Optional data object containing additional error information
|
taskInterrupted | () | method |
protected function taskInterrupted(message:String, data:* = null):void
Call this method to interrupt the currently running Task. This method dispatches a TaskEvent.INTERRUPTED and toggles the tasks's "running" state.
Parameters
message:String — An (optional) reason for the interruption
| |
data:* (default = null )
|
then | () | method |
public function then(... chainedTasks):ITask
Executes the specified tasks once the current task has completed successfully.
Parameters
... chainedTasks — One or more tasks
|
ITask |
throwErrorIfAnyObjectInArrayIsNotATask | () | method |
protected function throwErrorIfAnyObjectInArrayIsNotATask(tasks:Array):void
Parameters
tasks:Array |
withCompleteHandler | () | method |
public function withCompleteHandler(completeHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate completion, this method may also be used for notification purposes. The provided function will be invoked only upon successful completion of the task. This method may be called multiple times safely; each unique function specified will be executed once when the task completes.
It should have one of the following signatures:
function( message:String = "", data:= null ):void
function():void
Parameters
completeHandler:Function — Function
|
ITask |
withErrorHandler | () | method |
public function withErrorHandler(errorHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate failure, this method may also be used for notification purposes. The provided function will be invoked only upon failure of the task. This method may be called multiple times safely; each unique function specified will be executed once if the tasks errors.
It should have one of the following signatures:
function( message:String = "", data:= null ):void
function():void
Parameters
errorHandler:Function — Function
|
ITask |
withFinalHandler | () | method |
public function withFinalHandler(finalHandler:Function):ITask
This handler is invoked upon either success or failure of the Task. It can be used for cleanup that must be done regardless of Task-status.
This method may be called multiple times safely. Each unique function specified will be executed once when the task is ready for cleanup.
This type of closure should implement the following signature:
function():void
Parameters
finalHandler:Function |
ITask |
withInterruptionHandler | () | method |
public function withInterruptionHandler(interruptionHandler:Function):ITask
Parameters
interruptionHandler:Function |
ITask |
withStartedHandler | () | method |
public function withStartedHandler(startedHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate starting, this method may also be used for notification purposes. The provided function will be invoked each time the task is started (or re-started). This method may be called multiple times safely; each unique function specified will be executed once when the task starts.
It should have the following signature:
function():void
Parameters
startedHandler:Function — Function
|
ITask |
progress | Event |
flash.events.ProgressEvent
taskEventComplete | Event |
taskEventError | Event |
taskEventFinal | Event |
taskEventInterrupted | Event |
taskEventStarted | Event |