Packagecom.rosettastone.library.taskmanager
Classpublic class ObserverTask
InheritanceObserverTask Inheritance Task Inheritance flash.events.EventDispatcher

Observes (but does not execute) a collection of Tasks. This task can be used to monitor the execution of 1 or more running Tasks. Tasks can be added (or removed) while the observer is running. It will complete only once all observed Tasks has completed. If any of the observed Tasks errors, the observer will error as well if failUponError is TRUE. In this case the observer will re-dispatch the "data" and "message" properties of the first Task to fail. If failUponError is FALSE, observed Task errors and complets will be treated the same. If this Task is executed with no observed Tasks it will instantly complete. The same is true if all of its observed Tasks have already completed by the time it has been executed.



Public Properties
 PropertyDefined By
 Inheriteddata : *
[read-only] Optional data parameter passed to the Task complete/error/interruption method.
Task
 Inheritedid : Number
[read-only]
Task
 Inheritedinterruptible : Boolean
[read-only] The current Task can be interrupted.
Task
 InheritedinterruptingTask : ITask
[read-only] The Task currently interrupting the composite Task's execution (or NULL if no such Task exists).
Task
 InheritedisComplete : Boolean
[read-only] The current task has successfully completed execution.
Task
 InheritedisErrored : Boolean
[read-only] The current task failed.
Task
 InheritedisInterrupted : Boolean
[read-only]
Task
 InheritedisRunning : Boolean
[read-only] The task is currently running.
Task
 Inheritedmessage : String
[read-only] Optional message parameter passed to the task complete/error/interruption method.
Task
  numInternalOperations : int
[override] [read-only] Number of internal operations conducted by this task.
ObserverTask
  numInternalOperationsCompleted : int
[override] [read-only] Number of internal operations that have completed.
ObserverTask
 InheritednumInternalOperationsPending : int
[read-only] Number of internal operations not yet completed.
Task
 InheritednumTimesCompleted : int
[read-only] Number of times this task has completed.
Task
 InheritednumTimesErrored : int
[read-only] Number of times this task has errored.
Task
 InheritednumTimesInterrupted : int
[read-only] Number of times this task has been interrupted.
Task
 InheritednumTimesReset : int
[read-only] Number of times this task has been reset.
Task
 InheritednumTimesStarted : int
[read-only] Number of times this task has been started.
Task
 Inheritedrunning : Boolean
[read-only] The task is currently running.
Task
 Inheritedsynchronous : Boolean
[read-only] The current task can be executed synchronously.
Task
 InheritedtaskIdentifier : String
(Optional) human-readable label for task.
Task
 InheriteduniqueID : Number
[read-only] Unique ID for a task.
Task
Protected Properties
 PropertyDefined By
  _failUponError : Boolean
ObserverTask
 Inheritedlogger : ILogger
[read-only] Instance of ILogger to be used for any custom Task logging.
Task
  _observedTasks : Array
ObserverTask
Public Methods
 MethodDefined By
  
ObserverTask(tasks:Array = null, failUponError:Boolean = true, taskIdentifier:String = null)
Constructor.
ObserverTask
 Inherited
and(... chainedTasks):ITask
Executes the specified tasks when the current task is executed.
Task
 Inherited
Task
 Inherited
interrupt():Boolean
Interruptible tasks should override interrupt() and get interruptible() if they are interruptible.
Task
 Inherited
interruptForTask(interruptingTask:ITask):Boolean
Interrupts the current Task to wait on the Task specified.
Task
  
observeTask(taskToObserve:ITask):void
Add an additional Task to the set of Tasks being observed.
ObserverTask
 Inherited
or(... chainedTasks):ITask
Executes the specified tasks if the current task fails.
Task
 Inherited
reset():void
Resets the task to it's pre-run state.
Task
 Inherited
Starts a task.
Task
  
stopObservingTask(taskToObserve:ITask):void
Remove the specified Task from the set of Tasks being observed.
ObserverTask
 Inherited
then(... chainedTasks):ITask
Executes the specified tasks once the current task has completed successfully.
Task
 Inherited
withCompleteHandler(completeHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate completion, this method may also be used for notification purposes.
Task
 Inherited
withErrorHandler(errorHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate failure, this method may also be used for notification purposes.
Task
 Inherited
withFinalHandler(finalHandler:Function):ITask
This handler is invoked upon either success or failure of the Task.
Task
 Inherited
withInterruptionHandler(interruptionHandler:Function):ITask
Task
 Inherited
withStartedHandler(startedHandler:Function):ITask
Although tasks dispatch TaskEvents to indicate starting, this method may also be used for notification purposes.
Task
Protected Methods
 MethodDefined By
  
ObserverTask
  
ObserverTask
 Inherited
Override this method to perform any custom reset operations.
Task
  
customRun():void
[override] Override this method to give your Task functionality.
ObserverTask
 Inherited
Task
 Inherited
getLoggerString(string:String):String
Returns a string for logging the specified task-state event.
Task
 Inherited
taskComplete(message:String, data:* = null):void
This method should be called upon Task completion.
Task
 Inherited
taskError(message:String, data:* = null):void
This method should be called upon Task failure.
Task
 Inherited
taskInterrupted(message:String, data:* = null):void
Call this method to interrupt the currently running Task.
Task
 Inherited
Task
Events
 Event Summary Defined By
 InheritedTask
 InheritedTask
 InheritedTask
 InheritedTask
 InheritedTask
 InheritedTask
Property Detail
_failUponErrorproperty
protected var _failUponError:Boolean

_observedTasksproperty 
protected var _observedTasks:Array

numInternalOperationsproperty 
numInternalOperations:int  [read-only] [override]

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.


Implementation
    public function get numInternalOperations():int
numInternalOperationsCompletedproperty 
numInternalOperationsCompleted:int  [read-only] [override]

Number of internal operations that have completed. Sub-classes should override this method if containing a value > 1;


Implementation
    public function get numInternalOperationsCompleted():int
observedTasksproperty 
observedTasks:Array  [read-only]

Array of Tasks currently observed by this Task.


Implementation
    TaskPrivateNamespace function get observedTasks():Array
Constructor Detail
ObserverTask()Constructor
public function ObserverTask(tasks:Array = null, failUponError:Boolean = true, taskIdentifier:String = null)

Constructor.

Parameters
tasks:Array (default = null) — Array of Tasks to observe
 
failUponError:Boolean (default = true) — Controls behavior in the event of a Task error; see class documentation for more detail
 
taskIdentifier:String (default = null)
Method Detail
areAllObservedTasksCompletedOrErrored()method
protected function areAllObservedTasksCompletedOrErrored():Boolean

Returns
Boolean
checkForAndHandleCompletion()method 
protected function checkForAndHandleCompletion():void

customRun()method 
override protected function customRun():void

Override this method to give your Task functionality.

observeTask()method 
public function observeTask(taskToObserve:ITask):void

Add an additional Task to the set of Tasks being observed.

Parameters

taskToObserve:ITask

stopObservingTask()method 
public function stopObservingTask(taskToObserve:ITask):void

Remove the specified Task from the set of Tasks being observed.

Parameters

taskToObserve:ITask