Opened 6 years ago

Closed 6 years ago

#17411 closed defect (invalid)

dojo/promise/all buggy

Reported by: Wouter Hager Owned by:
Priority: undecided Milestone: tbd
Component: Core Version: 1.9.1
Keywords: Cc:
Blocked By: Blocking:

Description

The following code doesn't show anything on the console, so all().then is never executed.

require(["dojo/Deferred","dojo/promise/all"],function(Deferred,all){

var proms = [];

for(var i=0;i<3;i++) {

var d = new Deferred(); setTimeout(function(){

d.resolve(true);

},10); proms.push(d.promise);

}

all(proms).then(function(res){

console.log(res);

});

});

Change History (2)

comment:1 Changed 6 years ago by Wouter Hager

The following code works, so nevermind:

require(["dojo/Deferred","dojo/promise/all"],function(Deferred,all){
    var proms = [];
    var f = function(){
        var d = new Deferred();
        setTimeout(function(){
            d.resolve(true);
        },10)
        return d.promise;
    };
    
    for(var i=0;i<3;i++) {
        proms.push(f());
    }
    
    all(proms).then(function(res){
        console.log(res);
    });

});

comment:2 Changed 6 years ago by bill

Resolution: invalid
Status: newclosed

Right, the bug in your first code was that it resolved the third promise three times, and never resolved the first two.

Note: See TracTickets for help on using tickets.