Documentation generator: JsDoc Toolkit 2.4.0
Template: Codeview 1.2
Generated on: 2016-0-4 21:22

Class enchant.Deferred

Class Summary
Constructor Attributes Constructor Name and Description
 

Method Summary

Method Attributes Method Name and Description
 
call(arg)
 
error(func)
 
fail(arg)
 
next(func)
<static>  
enchant.Deferred.next(func)
<static>  
enchant.Deferred.parallel(arg)

Class Detail

enchant.Deferred()
enchant.Deferred
    .next(function() {
        return 42;
    })
    .next(function(n) {
        console.log(n); // 42
    })
    .next(function() {
        return core.load('img.png'); // wait loading
    })
    .next(function() {
        var img = core.assets['img.png'];
        console.log(img instanceof enchant.Surface); // true
        throw new Error('!!!');
    })
    .next(function() {
        // skip
    })
    .error(function(err) {
         console.log(err.message); // !!!
    });

Method Detail

  • call(arg)
    Parameters:
    {*} arg
  • error(func)
    Parameters:
    {Function} func
  • fail(arg)
    Parameters:
    {*} arg
  • Parameters:
    {Function} func
  • <static> {enchant.Deferred} enchant.Deferred.next(func)
    Parameters:
    {Function} func
    Returns:
    {enchant.Deferred}
  • <static> {enchant.Deferred} enchant.Deferred.parallel(arg)
    // array
    enchant.Deferred
        .parallel([
            enchant.Deferred.next(function() {
                return 24;
            }),
            enchant.Deferred.next(function() {
                return 42;
            })
        ])
        .next(function(arg) {
            console.log(arg); // [ 24, 42 ]
        });
    // object
    enchant.Deferred
        .parallel({
            foo: enchant.Deferred.next(function() {
                return 24;
            }),
            bar: enchant.Deferred.next(function() {
                return 42;
            })
        })
        .next(function(arg) {
            console.log(arg.foo); // 24
            console.log(arg.bar); // 42
        });
    Parameters:
    {Object|enchant.Deferred[]} arg
    Returns:
    {enchant.Deferred}