]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/_base/Deferred.js
2 Copyright (c) 2004-2010, 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
8 if(!dojo
._hasResource
["dojo._base.Deferred"]){
9 dojo
._hasResource
["dojo._base.Deferred"]=true;
10 dojo
.provide("dojo._base.Deferred");
11 dojo
.require("dojo._base.lang");
15 var _2
=Object
.freeze
||function(){
17 dojo
.Deferred=function(_3
){
19 var _9
=this.promise
={};
22 throw new Error("This deferred has already been resolved");
33 if(_d
=(_e
.progress
==_1
)){
36 var _f
=(_6
?_e
.error
:_e
.resolved
);
40 if(_10
&&typeof _10
.then
==="function"){
41 _10
.then(dojo
.hitch(_e
.deferred
,"resolve"),dojo
.hitch(_e
.deferred
,"reject"));
44 var _11
=_d
&&_10
===undefined;
45 _e
.deferred
[_11
&&_6
?"reject":"resolve"](_11
?_4
:_10
);
48 _e
.deferred
.reject(e
);
52 _e
.deferred
.reject(_4
);
54 _e
.deferred
.resolve(_4
);
59 this.resolve
=this.callback=function(_12
){
61 this.results
=[_12
,null];
64 this.reject
=this.errback=function(_13
){
68 this.results
=[null,_13
];
69 if(!_13
||_13
.log
!==false){
70 (dojo
.config
.deferredOnError
||function(x
){
75 this.progress=function(_14
){
83 this.addCallbacks=function(_17
,_18
){
84 this.then(_17
,_18
,_1
);
87 this.then
=_9
.then=function(_19
,_1a
,_1b
){
88 var _1c
=_1b
==_1
?this:new dojo
.Deferred(_9
.cancel
);
89 var _1d
={resolved
:_19
,error
:_1a
,progress
:_1b
,deferred
:_1c
};
101 this.cancel
=_9
.cancel=function(){
105 if(!(_1f
instanceof Error
)){
115 dojo
.extend(dojo
.Deferred
,{addCallback:function(_20
){
116 return this.addCallbacks(dojo
.hitch
.apply(dojo
,arguments
));
117 },addErrback:function(_21
){
118 return this.addCallbacks(null,dojo
.hitch
.apply(dojo
,arguments
));
119 },addBoth:function(_22
){
120 var _23
=dojo
.hitch
.apply(dojo
,arguments
);
121 return this.addCallbacks(_23
,_23
);
124 dojo
.when=function(_24
,_25
,_26
,_27
){
125 if(_24
&&typeof _24
.then
==="function"){
126 return _24
.then(_25
,_26
,_27
);