TaskGroup

clay.async. TaskGroup

# new TaskGroup()

Source:

Extends

Methods

# after(name, action, contextopt)

Source:
Inherited From:
Mixes In:

Alias of once('after' + name)

Parameters:
Name Type Attributes Description
name string
action function
context Object <optional>

# all(tasks)

Source:

Wait for all given tasks successed, task can also be any notifier object which will trigger success and error events. Like clay.Texture2D, clay.TextureCube, clay.loader.GLTF.

Example
// Load texture list
    var list = ['a.jpg', 'b.jpg', 'c.jpg']
    var textures = list.map(function (src) {
        var texture = new clay.Texture2D();
        texture.load(src);
        return texture;
    });
    var taskGroup = new clay.async.TaskGroup();
    taskGroup.all(textures).success(function () {
        // Do some thing after all textures loaded
    });
Parameters:
Name Type Description
tasks Array.<clay.async.Task>

# allSettled(tasks) → {clay.async.TaskGroup}

Source:

Wait for all given tasks finished, either successed or failed

Parameters:
Name Type Description
tasks Array.<clay.async.Task>
Returns:
Type
clay.async.TaskGroup

# before(name, action, contextopt)

Source:
Inherited From:
Mixes In:

Alias of once('before' + name)

Parameters:
Name Type Attributes Description
name string
action function
context Object <optional>

# error(action, contextopt)

Source:
Inherited From:
Mixes In:

Alias of on('error')

Parameters:
Name Type Attributes Description
action function
context Object <optional>

# getFulfilledNumber(recursiveopt) → {number}

Source:

Get successed sub tasks number, recursive can be true if sub task is also a TaskGroup.

Parameters:
Name Type Attributes Description
recursive boolean <optional>
Returns:
Type
number

# getRejectedNumber(recursiveopt) → {number}

Source:

Get failed sub tasks number, recursive can be true if sub task is also a TaskGroup.

Parameters:
Name Type Attributes Description
recursive boolean <optional>
Returns:
Type
number

# getSettledNumber(recursiveopt) → {number}

Source:

Get finished sub tasks number, recursive can be true if sub task is also a TaskGroup.

Parameters:
Name Type Attributes Description
recursive boolean <optional>
Returns:
Type
number

# getTaskNumber(recursiveopt) → {number}

Source:

Get all sub tasks number, recursive can be true if sub task is also a TaskGroup.

Parameters:
Name Type Attributes Description
recursive boolean <optional>
Returns:
Type
number

# has(name, action) → {boolean}

Source:
Inherited From:
Mixes In:

If registered the event handler

Parameters:
Name Type Description
name string
action function
Returns:
Type
boolean

# isFullfilled() → {boolean}

Source:
Inherited From:

If task successed

Returns:
Type
boolean

# isRejected() → {boolean}

Source:
Inherited From:

If task failed

Returns:
Type
boolean

# isSettled() → {boolean}

Source:
Inherited From:

If task finished, either successed or failed

Returns:
Type
boolean

# off(action, contextopt)

Source:
Inherited From:
Mixes In:

Remove event listener

Parameters:
Name Type Attributes Description
action function
context Object <optional>

# on(name, action, contextopt)

Source:
Inherited From:
Mixes In:

Register event handler

Parameters:
Name Type Attributes Description
name string
action function
context Object <optional>

# once(name, action, contextopt)

Source:
Inherited From:
Mixes In:

Register event, event will only be triggered once and then removed

Parameters:
Name Type Attributes Description
name string
action function
context Object <optional>

# reject(err)

Source:
Inherited From:

Task failed

Parameters:
Name Type Description
err

# resolve(data)

Source:
Inherited From:

Task successed

Parameters:
Name Type Description
data

# success(action, contextopt)

Source:
Inherited From:
Mixes In:

Alias of on('success')

Parameters:
Name Type Attributes Description
action function
context Object <optional>

# trigger(name)

Source:
Inherited From:
Mixes In:

Trigger event

Parameters:
Name Type Description
name string