Class enchant.Deferred
See:
http://cho45.stfuawsc.com/jsdeferred/
- Defined in: enchant.js
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
-
next(func)
- Parameters:
- {Function} func
-
- Parameters:
- {Function} func
- Returns:
- {enchant.Deferred}
-
// 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}