Select to view content in your preferred language

dojo/promise/all - What if one of the deferreds is not resolved?

1905
1
11-15-2013 01:32 AM
RichardBetts
Deactivated User
Hi

The 'Manage results from multiple queries' sample demonstrates how to use dojo/promise/all rather than dojo/DeferredList to query multiple layers simultaneously and process the results when all the queries have finished.
The results available in the DeferredList callback would be a 2 dimensional array, the first element in each array would be a true/false flag to indicate whether the individual deferred in question (individual querytask) resolved successfully or not.

I am finding that the callback for promise/all never fires if any of the individual deferreds is not resolved (perhaps the querytask was attempting to use an incorrect layer ID, timeout etc) 

I am also trying to use promise/all to handle a series of esri.request requests to a number of layer endpoints to check layer availability and again the callback never fires if any of the individual requests returns an error or times out. 

Can anyone give me any pointers as to how to handle this?

Many Thanks

Richard
0 Kudos
1 Reply
RichardBetts
Deactivated User
Hi.
OK, so I've worked out I can use the 'always' method rather than the 'then' method to trigger the callback even if one of the individual deferreds returns an error, but I still cannot access the other (successful) results in the callback?

Do I need separate callbacks?

Again, DeferredList would return an array of results the same length and in the same order as the array that was supplied.
You could then filter out any errors and process the successful results, knowing for example that item 4 in the array of results corresponded to item 4 in the array of individual deferreds supplied to DeferredList. 

Can anyone help?
Thanks, Richard
0 Kudos