Skip to content

Commit

Permalink
Change to 'then' for common promise object
Browse files Browse the repository at this point in the history
  • Loading branch information
arronzhang committed Dec 14, 2011
1 parent 92c1892 commit 62037c8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/util.js
Expand Up @@ -134,7 +134,7 @@ function and ( firstParam ) {
}

var dfd = jQuery.Deferred();
this.done( function() {
this.then( function() {
var last = slice.call( arguments )
, res;
try {
Expand All @@ -146,17 +146,17 @@ function and ( firstParam ) {
dfd.reject( res );
} else {
res = isFunction( res && res.promise ) ? res : jQuery.when( res );
res.done( function( value ) {
res.then( function( value ) {
var args = [ arguments.length > 1 ? slice.call( arguments, 0 ) : value ]
, i = last.length;
while( i ) {
args.unshift( last[ --i ] );
}
dfd.resolve.apply( dfd, args );
} ).fail( dfd.reject );
}, dfd.reject );
}

} ).fail( dfd.reject );
}, dfd.reject );

var promise = dfd.promise();
promise.and = and;
Expand Down Expand Up @@ -210,7 +210,7 @@ function and ( firstParam ) {
}

var dfd = jQuery.Deferred();
this.done( function() {
this.then( function() {
var last = slice.call( arguments )
, res;
try {
Expand All @@ -222,13 +222,13 @@ function and ( firstParam ) {
dfd.reject( res );
} else {
res = isFunction( res && res.promise ) ? res : jQuery.when( res );
res.done( function( value ) {
res.then( function( value ) {
var args = [ arguments.length > 1 ? slice.call( arguments, 0 ) : value ];
dfd.resolve.apply( dfd, args );
} ).fail( dfd.reject );
}, dfd.reject );
}

} ).fail( dfd.reject );
}, dfd.reject );

var promise = dfd.promise();
promise.next = next;
Expand Down

0 comments on commit 62037c8

Please sign in to comment.