diff options
Diffstat (limited to 'src/deferred.js')
-rw-r--r-- | src/deferred.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/deferred.js b/src/deferred.js index 9e5f5110a..457bc521f 100644 --- a/src/deferred.js +++ b/src/deferred.js @@ -9,6 +9,7 @@ jQuery.extend({ var doneList = jQuery.Callbacks( "once memory" ), failList = jQuery.Callbacks( "once memory" ), progressList = jQuery.Callbacks( "memory" ), + state = "pending", lists = { resolve: doneList, reject: failList, @@ -19,11 +20,13 @@ jQuery.extend({ fail: failList.add, progress: progressList.add, + state: function() { + return state; + }, + + // Deprecated isResolved: doneList.fired, isRejected: failList.fired, - isPending: function() { - return !progressList.locked(); - }, then: function( doneCallbacks, failCallbacks, progressCallbacks ) { deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks ); @@ -78,9 +81,12 @@ jQuery.extend({ deferred[ key + "With" ] = lists[ key ].fireWith; } - // Handle lists exclusiveness - deferred.done( failList.disable, progressList.lock ) - .fail( doneList.disable, progressList.lock ); + // Handle state + deferred.done( function() { + state = "resolved"; + }, failList.disable, progressList.lock ).fail( function() { + state = "rejected"; + }, doneList.disable, progressList.lock ); // Call given func if any if ( func ) { |