AnsweredAssumed Answered

Need help converting a DeferredList to use dojo/promise/all

Question asked by alanabaker on Dec 2, 2014
Latest reply on Dec 2, 2014 by oearley

I need some help before I lose what shred of sanity I have left.  Let me start out by saying that I am pretty new to JavaScript and dojo. I am trying to rewrite our JS maps to AMD and have hit a wall when it comes to converting a DeferredList to the new dojo/promise API.


Not to overwhelm you with code, I'll just paste a snippet of the "old" code (I am aware of converting to etc. but just want to show what I'm starting with).


var tasks =, function(layer) {

                    return new esri.tasks.IdentifyTask(layer.url);

//map each visible dynamic layer to a new identify task, using the layer url

                var defTasks =, function (task) {

                    return new dojo.Deferred();

//map each identify task to a new dojo.Deferred


                var dlTasks = new dojo.DeferredList(defTasks); //And use all of these Deferreds in a DeferredList

                dlTasks.then(showIDResults); //chain showResults nto your DeferredList ***PROBLEM HERE****

                idParams.width = map.width;

                idParams.height = map.height;

                idParams.geometry = evt.mapPoint;

                idParams.mapExtent = map.extent;


                for (i=0;i<tasks.length;i++) { //Use 'for' instead of '' so you can sync tasks with defTasks

                    try {

                        tasks[i].execute(idParams, defTasks[i].callback, defTasks[i].errback); //Execute each task

                    catch (e) {

                        console.log("Error caught");


                        defTasks[i].errback(e); //If you get an error for any task, execute the errback




The showIDResults function expects an array of results from execution of the tasks.  This is were I'm having a problem. No matter what I try (and I've tried a lot of things) I end up with a Deferred or a Promise rather than actual results to pass to showIDResults.


Am I making any sense? Any help would be greatly appreciated!