API Documentation for: 1.0.0
Show:

TaskManager Class

Defined in: TaskManager:9
Namespace: cloudkid

The task manager is responsible for doing a series of asyncronous tasks

Constructor

TaskManager

(
  • tasks
)

Defined in TaskManager:9

Parameters:

  • tasks Array

    The series of tasks to do

Methods

addEventListener

(
  • type
  • listener
)
Function | Object

Defined in addEventListener:24

Adds the specified event listener

Parameters:

  • type String

    The string type of the event

  • listener Function | Object

    An object with a handleEvent method, or a function that will be called when the event is dispatched

Returns:

Function | Object:

Returns the listener for chaining or assignment

addTask

(
  • task
)

Defined in addTask:185

Convenience function to add a task

Parameters:

  • task Task

    The task object to load

addTasks

(
  • tasks
)

Defined in addTasks:196

Add bunch of tasks

Parameters:

  • tasks Array

    Collection of tasks to add

cancelTask

(
  • taskId
)

Defined in cancelTask:239

Cancels all tasks with a given id

Parameters:

  • taskId String

    The task id to remove.

destroy

()

Defined in destroy:376

We don't want to use the task manager after this

dispatchEvent

(
  • enventObj
  • target
)
Bool

Defined in dispatchEvent:48

Dispatches the specified event

Parameters:

  • enventObj Object | String

    An object with a "type" property, or a string type

  • target Object

    The object to use as the target property of the event object

Returns:

Bool:

Returns true if any listener returned true

hasEventListener

(
  • type
)
Bool

Defined in hasEventListener:57

Indicates whether there is at least one listener for the specified event type

Parameters:

  • type String

    The string type of the event

Returns:

Bool:

Returns true if there is at least one listener for the specified event

initialize

(
  • tasks
)

Defined in initialize:173

Initializes the task manager

Parameters:

  • tasks Array

    The optional array of tasks, we can also add this later

onTaskDone

(
  • result
  • task
)

Defined in onTaskDone:314

Callback for when an task is done

Parameters:

  • result

    Result of the task

  • task Task

    Task that is done

process

(
  • tasks
  • callback
  • [startAll=true]
  • [immediateDestroy=true]
)
TaskManager static

Defined in process:131

Convenience method to execute tasks without having to setup the event listener

Parameters:

  • tasks Array

    The collection of tasks

  • callback Function

    The callback

  • [startAll=true] Boolean optional

    If we should start all tasks

  • [immediateDestroy=true] Boolean optional

    Destroy after load

Returns:

TaskManager:

The instance of the task manager created

removeAll

()

Defined in removeAll:209

Cancel and remove all tasks

removeAllEventListeners

(
  • type
)

Removes all listeners for the specified type, or all listeners of all types

Parameters:

  • type String

    The string type of the event. If omitted, all listeners for all types will be removed.

removeEventListener

(
  • type
  • listener
)

Removes the specified event listener

Parameters:

  • type String

    The string type of the event

  • listener Function | Object

    The listener function or object

startAll

() Array

Defined in startAll:353

Start the next task until there are no more tasks to start

Returns:

Array:

All tasks that were started

startNext

() Task

Defined in startNext:271

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:

Task:

The task that was started or null if the list contained no tasks to be processed

Properties

_currentTaskes

Array private

Defined in _currentTaskes:99

The current tasks

_isDestroyed

Bool private

Defined in _isDestroyed:123

If the manager is destroyed

_listeners description

Array private

Createjs EventDispatcher method

_tasksInProgress

Int private

The number of tasks that are currently in progress

paused

Bool

Defined in paused:107

If we're paused and should therefore not automatically proceed to the next task after each task completes

tasks

Array

Defined in tasks:92

Collection of all tasks

VERSION

String final static

Defined in VERSION:76

The current version of the state manager

Events

onAllTasksDone

Defined in onAllTasksDone:85

Event dispatched when tasks are all done