TaskManager Class
The task manager is responsible for doing a series of asyncronous tasks
Constructor
Item Index
Methods
Properties
Events
Methods
cancelTask
-
taskId
Cancels all tasks with a given id
Parameters:
-
taskId
StringThe task id to remove.
destroy
()
We don't want to use the task manager after this
dispatchEvent
-
enventObj
-
target
Dispatches the specified event
Parameters:
Returns:
Returns true if any listener returned true
hasEventListener
-
type
Indicates whether there is at least one listener for the specified event type
Parameters:
-
type
StringThe string type of the event
Returns:
Returns true if there is at least one listener for the specified event
initialize
-
tasks
Initializes the task manager
Parameters:
-
tasks
ArrayThe optional array of tasks, we can also add this later
onTaskDone
-
result
-
task
Callback for when an task is done
Parameters:
-
result
Result of the task
-
task
TaskTask that is done
process
-
tasks
-
callback
-
[startAll=true]
-
[immediateDestroy=true]
Convenience method to execute tasks without having to setup the event listener
Parameters:
Returns:
The instance of the task manager created
removeAll
()
Cancel and remove all tasks
removeAllEventListeners
-
type
Removes all listeners for the specified type, or all listeners of all types
Parameters:
-
type
StringThe string type of the event. If omitted, all listeners for all types will be removed.
removeEventListener
-
type
-
listener
Removes the specified event listener
startAll
()
Array
Start the next task until there are no more tasks to start
Returns:
All tasks that were started
startNext
()
Task
Start the next task in the tasks list. When it is done, the task's callback will be called. If the manager is not paused after the task's callback returns, the manager will start the next task.
Returns:
The task that was started or null if the list contained no tasks to be processed
Properties
_isDestroyed
Bool
private
If the manager is destroyed
_tasksInProgress
Int
private
The number of tasks that are currently in progress
paused
Bool
If we're paused and should therefore not automatically proceed to the next task after each task completes
Events
onAllTasksDone
Event dispatched when tasks are all done