mirror of
https://github.com/adelphes/android-dev-ext.git
synced 2025-12-23 01:48:18 +00:00
jq promise fixes
return promise in always() allow when() to accept a single array of arguments
This commit is contained in:
@@ -32,7 +32,7 @@ var Deferred = exports.Deferred = function(p, parent) {
|
|||||||
var thendef = this.then(fn);
|
var thendef = this.then(fn);
|
||||||
this.fail(function() {
|
this.fail(function() {
|
||||||
// we cannot bind thendef to the function because we need the caller's this to resolve the thendef
|
// we cannot bind thendef to the function because we need the caller's this to resolve the thendef
|
||||||
thendef.resolveWith(this, Array.prototype.map.call(arguments,x=>x));
|
return thendef.resolveWith(this, Array.prototype.map.call(arguments,x=>x))._promise;
|
||||||
});
|
});
|
||||||
return thendef;
|
return thendef;
|
||||||
},
|
},
|
||||||
@@ -108,6 +108,9 @@ var Deferred = exports.Deferred = function(p, parent) {
|
|||||||
// $.when() is jQuery's version of Promise.all()
|
// $.when() is jQuery's version of Promise.all()
|
||||||
// - this version just scans the array of arguments waiting on any Deferreds in turn before finally resolving the return Deferred
|
// - this version just scans the array of arguments waiting on any Deferreds in turn before finally resolving the return Deferred
|
||||||
var when = exports.when = function() {
|
var when = exports.when = function() {
|
||||||
|
if (arguments.length === 1 && Array.isArray(arguments[0])) {
|
||||||
|
return when.apply(this,...arguments).then(() => [...arguments]);
|
||||||
|
}
|
||||||
var x = {
|
var x = {
|
||||||
def: $.Deferred(),
|
def: $.Deferred(),
|
||||||
args: Array.prototype.map.call(arguments,x=>x),
|
args: Array.prototype.map.call(arguments,x=>x),
|
||||||
|
|||||||
Reference in New Issue
Block a user