Changeset 12828
- Timestamp:
- 03/03/08 04:13:09 (9 months ago)
- Location:
- dojo/trunk
- Files:
-
- 2 modified
-
tests/_base/Deferred.js (modified) (1 diff)
-
_base/Deferred.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dojo/trunk/tests/_base/Deferred.js
r8301 r12828 19 19 // t.debug("cnt:", cnt); 20 20 t.assertEqual(cnt, 5); 21 }, 22 23 function callback_extra_args(t){ 24 var nd = new dojo.Deferred(); 25 var cnt = 0; 26 nd.addCallback(window, function(base, res){ cnt+=base; cnt+=res; return cnt; }, 30); 27 nd.callback(5); 28 t.assertEqual(cnt, 35); 21 29 }, 22 30 -
dojo/trunk/_base/Deferred.js
r11356 r12828 301 301 302 302 callback: function(res){ 303 // summary: Begin the callback sequence with a non-error value. 303 // summary: 304 // Begin the callback sequence with a non-error value. 304 305 305 306 /* … … 312 313 313 314 errback: function(/*Error*/res){ 314 // summary:315 // summary: 315 316 // Begin the callback sequence with an error result. 316 317 this._check(); … … 321 322 }, 322 323 323 addBoth: function(/*Function| |Object*/cb, /*Optional, String*/cbfn){324 // summary:324 addBoth: function(/*Function|Object*/cb, /*String?*/cbfn){ 325 // summary: 325 326 // Add the same function as both a callback and an errback as the 326 // next element on the callback sequence. This is useful for code327 // next element on the callback sequence.This is useful for code 327 328 // that you want to guarantee to run, e.g. a finalizer. 328 var enclosed = dojo.hitch(cb, cbfn); 329 if(arguments.length > 2){ 330 enclosed = dojo.partial(enclosed, arguments, 2); 331 } 329 var enclosed = dojo.hitch.apply(dojo, arguments); 332 330 return this.addCallbacks(enclosed, enclosed); 333 331 }, 334 332 335 addCallback: function( cb, cbfn){336 // summary:333 addCallback: function(/*Function|Object*/cb, /*String?*/cbfn /*...*/){ 334 // summary: 337 335 // Add a single callback to the end of the callback sequence. 338 var enclosed = dojo.hitch(cb, cbfn); 339 if(arguments.length > 2){ 340 enclosed = dojo.partial(enclosed, arguments, 2); 341 } 342 return this.addCallbacks(enclosed, null); 336 return this.addCallbacks(dojo.hitch.apply(dojo, arguments)); 343 337 }, 344 338 345 339 addErrback: function(cb, cbfn){ 346 // summary:340 // summary: 347 341 // Add a single callback to the end of the callback sequence. 348 var enclosed = dojo.hitch(cb, cbfn); 349 if(arguments.length > 2){ 350 enclosed = dojo.partial(enclosed, arguments, 2); 351 } 352 return this.addCallbacks(null, enclosed); 342 return this.addCallbacks(null, dojo.hitch.apply(dojo, arguments)); 353 343 }, 354 344