Task

clay.async. Task

# new Task()

Source:
Mixes In:

Methods

# (static) makeRequestTask(url, responseTypeopt) → {clay.async.Task|Array.<clay.async.Task>}

Source:

Make a request task

Example
var task = Task.makeRequestTask('./a.json');
    var task = Task.makeRequestTask({
        url: 'b.bin',
        responseType: 'arraybuffer'
    });
    var tasks = Task.makeRequestTask(['./a.json', './b.json']);
    var tasks = Task.makeRequestTask([
        {url: 'a.json'},
        {url: 'b.bin', responseType: 'arraybuffer'}
    ]);
Parameters:
Name Type Attributes Description
url string | object | Array.<object> | Array.<string>
responseType string <optional>
Returns:
Type
clay.async.Task | Array.<clay.async.Task>

# (static) makeTask() → {clay.async.Task}

Source:
Returns:
Type
clay.async.Task

# after(name, action, contextopt)

Source:
Mixes In:

Alias of once('after' + name)

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

# before(name, action, contextopt)

Source:
Mixes In:

Alias of once('before' + name)

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

# error(action, contextopt)

Source:
Mixes In:

Alias of on('error')

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

# has(name, action) → {boolean}

Source:
Mixes In:

If registered the event handler

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

# isFullfilled() → {boolean}

Source:

If task successed

Returns:
Type
boolean

# isRejected() → {boolean}

Source:

If task failed

Returns:
Type
boolean

# isSettled() → {boolean}

Source:

If task finished, either successed or failed

Returns:
Type
boolean

# off(action, contextopt)

Source:
Mixes In:

Remove event listener

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

# on(name, action, contextopt)

Source:
Mixes In:

Register event handler

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

# once(name, action, contextopt)

Source:
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:

Task failed

Parameters:
Name Type Description
err

# resolve(data)

Source:

Task successed

Parameters:
Name Type Description
data

# success(action, contextopt)

Source:
Mixes In:

Alias of on('success')

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

# trigger(name)

Source:
Mixes In:

Trigger event

Parameters:
Name Type Description
name string