1
|
/*
|
2
|
Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved.
|
3
|
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4
|
see: http://dojotoolkit.org/license for details
|
5
|
*/
|
6
|
|
7
|
|
8
|
if(!dojo._hasResource["dojo.DeferredList"]){
|
9
|
dojo._hasResource["dojo.DeferredList"]=true;
|
10
|
dojo.provide("dojo.DeferredList");
|
11
|
dojo.declare("dojo.DeferredList",dojo.Deferred,{constructor:function(_1,_2,_3,_4,_5){
|
12
|
this.list=_1;
|
13
|
this.resultList=new Array(this.list.length);
|
14
|
this.chain=[];
|
15
|
this.id=this._nextId();
|
16
|
this.fired=-1;
|
17
|
this.paused=0;
|
18
|
this.results=[null,null];
|
19
|
this.canceller=_5;
|
20
|
this.silentlyCancelled=false;
|
21
|
if(this.list.length===0&&!_2){
|
22
|
this.callback(this.resultList);
|
23
|
}
|
24
|
this.finishedCount=0;
|
25
|
this.fireOnOneCallback=_2;
|
26
|
this.fireOnOneErrback=_3;
|
27
|
this.consumeErrors=_4;
|
28
|
dojo.forEach(this.list,function(d,_7){
|
29
|
d.addCallback(this,function(r){
|
30
|
this._cbDeferred(_7,true,r);
|
31
|
return r;
|
32
|
});
|
33
|
d.addErrback(this,function(r){
|
34
|
this._cbDeferred(_7,false,r);
|
35
|
return r;
|
36
|
});
|
37
|
},this);
|
38
|
},_cbDeferred:function(_a,_b,_c){
|
39
|
this.resultList[_a]=[_b,_c];
|
40
|
this.finishedCount+=1;
|
41
|
if(this.fired!==0){
|
42
|
if(_b&&this.fireOnOneCallback){
|
43
|
this.callback([_a,_c]);
|
44
|
}else{
|
45
|
if(!_b&&this.fireOnOneErrback){
|
46
|
this.errback(_c);
|
47
|
}else{
|
48
|
if(this.finishedCount==this.list.length){
|
49
|
this.callback(this.resultList);
|
50
|
}
|
51
|
}
|
52
|
}
|
53
|
}
|
54
|
if(!_b&&this.consumeErrors){
|
55
|
_c=null;
|
56
|
}
|
57
|
return _c;
|
58
|
},gatherResults:function(_d){
|
59
|
var d=new dojo.DeferredList(_d,false,true,false);
|
60
|
d.addCallback(function(_f){
|
61
|
var ret=[];
|
62
|
dojo.forEach(_f,function(_11){
|
63
|
ret.push(_11[1]);
|
64
|
});
|
65
|
return ret;
|
66
|
});
|
67
|
return d;
|
68
|
}});
|
69
|
}
|