I have an array of Deferred objects, which I’m trying to map to their resolved values once they complete. I want to return the array when everything finishes resolving.
Here’s what I have so far:
$.when.apply(null, deferredArray)
.pipe(function(){
return deferredArray;
});
Unfortunately, this returns the array of Deferred objects in the resolved state.
Is there any way I can directly access the resolved elements? I know I can chain .then and .pipe on the resolved array of Deferred objects individually, but this doesn’t work well for my purposes.
Deferred objects are not designed to return any values. You have to handle the results in callbacks.
The results are passed as arguments to the
done,failorpipecallbacks:Of couse in you can also just set that function as callback:
DEMO