Side navigation
#9386 closed feature (wontfix)
Opened May 22, 2011 07:03PM UTC
Closed June 06, 2011 06:50PM UTC
Last modified September 13, 2012 12:21PM UTC
Deferreds Feature Request
Reported by: | alan.spacer@mailinator.com | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.7 |
Component: | deferred | Version: | 1.6.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Wherein a features for jQuery's Deferred objects are proposed:
When you want to take an action for when ALL Deferred objects are resolved or rejected (ie. not unresolved), you have to wrap a secondary Deferred object around each of them, and ensure that these secondary Deferreds are always resolved. This is because in the multiple Deferreds case where one of the Deferreds is rejected, ""jQuery.when"" IMMEDIATELY FIRES the fail callbacks for its master Deferred, even if some of the Deferreds may still be unresolved at that point.
Attachments (0)
Change History (12)
Changed May 22, 2011 07:27PM UTC by comment:1
keywords: | → 1.7-discuss |
---|
Changed May 22, 2011 08:35PM UTC by comment:2
description: | Wherein a features for jQuery's Deferred objects are proposed: \ \ When you want to take an action for when ALL Deferred objects are resolved or rejected (ie. not unresolved), you have to wrap a secondary Deferred object around each of them, and ensure that these secondary Deferreds are always resolved. This is because in the multiple Deferreds case where one of the Deferreds is rejected, ""jQuery.when"" IMMEDIATELY FIRES the fail callbacks for its master Deferred, even if some of the Deferreds may still be unresolved at that point. \ \ See: http://stackoverflow.com/questions/5824615/ → Wherein a features for jQuery's Deferred objects are proposed:\ \ When you want to take an action for when ALL Deferred objects are resolved or rejected (ie. not unresolved), you have to wrap a secondary Deferred object around each of them, and ensure that these secondary Deferreds are always resolved. This is because in the multiple Deferreds case where one of the Deferreds is rejected, ""jQuery.when"" IMMEDIATELY FIRES the fail callbacks for its master Deferred, even if some of the Deferreds may still be unresolved at that point.\ \ See: http://stackoverflow.com/questions/5824615/ |
---|
+0,
Changed May 23, 2011 01:00AM UTC by comment:3
-1, Start with a plugin, I'll gladly incorporate this in ajaxHooks (which I'd like to have some deferred helpers too)
Changed May 23, 2011 05:02AM UTC by comment:4
+0, I like the idea.
Changed May 24, 2011 01:00AM UTC by comment:5
component: | unfiled → deferred |
---|---|
description: | Wherein a features for jQuery's Deferred objects are proposed:\ \ When you want to take an action for when ALL Deferred objects are resolved or rejected (ie. not unresolved), you have to wrap a secondary Deferred object around each of them, and ensure that these secondary Deferreds are always resolved. This is because in the multiple Deferreds case where one of the Deferreds is rejected, ""jQuery.when"" IMMEDIATELY FIRES the fail callbacks for its master Deferred, even if some of the Deferreds may still be unresolved at that point.\ \ See: http://stackoverflow.com/questions/5824615/ → Wherein a features for jQuery's Deferred objects are proposed: \ \ When you want to take an action for when ALL Deferred objects are resolved or rejected (ie. not unresolved), you have to wrap a secondary Deferred object around each of them, and ensure that these secondary Deferreds are always resolved. This is because in the multiple Deferreds case where one of the Deferreds is rejected, ""jQuery.when"" IMMEDIATELY FIRES the fail callbacks for its master Deferred, even if some of the Deferreds may still be unresolved at that point. \ \ See: http://stackoverflow.com/questions/5824615/ |
priority: | undecided → low |
status: | new → open |
Changed May 24, 2011 10:17PM UTC by comment:6
-1, Plugin first?
Changed June 03, 2011 02:09PM UTC by comment:7
description: | Wherein a features for jQuery's Deferred objects are proposed: \ \ When you want to take an action for when ALL Deferred objects are resolved or rejected (ie. not unresolved), you have to wrap a secondary Deferred object around each of them, and ensure that these secondary Deferreds are always resolved. This is because in the multiple Deferreds case where one of the Deferreds is rejected, ""jQuery.when"" IMMEDIATELY FIRES the fail callbacks for its master Deferred, even if some of the Deferreds may still be unresolved at that point. \ \ See: http://stackoverflow.com/questions/5824615/ → Wherein a features for jQuery's Deferred objects are proposed:\ \ When you want to take an action for when ALL Deferred objects are resolved or rejected (ie. not unresolved), you have to wrap a secondary Deferred object around each of them, and ensure that these secondary Deferreds are always resolved. This is because in the multiple Deferreds case where one of the Deferreds is rejected, ""jQuery.when"" IMMEDIATELY FIRES the fail callbacks for its master Deferred, even if some of the Deferreds may still be unresolved at that point.\ \ See: http://stackoverflow.com/questions/5824615/ |
---|
+0
Changed June 05, 2011 10:26PM UTC by comment:8
description: | Wherein a features for jQuery's Deferred objects are proposed:\ \ When you want to take an action for when ALL Deferred objects are resolved or rejected (ie. not unresolved), you have to wrap a secondary Deferred object around each of them, and ensure that these secondary Deferreds are always resolved. This is because in the multiple Deferreds case where one of the Deferreds is rejected, ""jQuery.when"" IMMEDIATELY FIRES the fail callbacks for its master Deferred, even if some of the Deferreds may still be unresolved at that point.\ \ See: http://stackoverflow.com/questions/5824615/ → Wherein a features for jQuery's Deferred objects are proposed: \ \ When you want to take an action for when ALL Deferred objects are resolved or rejected (ie. not unresolved), you have to wrap a secondary Deferred object around each of them, and ensure that these secondary Deferreds are always resolved. This is because in the multiple Deferreds case where one of the Deferreds is rejected, ""jQuery.when"" IMMEDIATELY FIRES the fail callbacks for its master Deferred, even if some of the Deferreds may still be unresolved at that point. \ \ See: http://stackoverflow.com/questions/5824615/ |
---|
+1, I kind of think it's a bug that they don't work this way already.
Changed June 06, 2011 02:59PM UTC by comment:9
description: | Wherein a features for jQuery's Deferred objects are proposed: \ \ When you want to take an action for when ALL Deferred objects are resolved or rejected (ie. not unresolved), you have to wrap a secondary Deferred object around each of them, and ensure that these secondary Deferreds are always resolved. This is because in the multiple Deferreds case where one of the Deferreds is rejected, ""jQuery.when"" IMMEDIATELY FIRES the fail callbacks for its master Deferred, even if some of the Deferreds may still be unresolved at that point. \ \ See: http://stackoverflow.com/questions/5824615/ → Wherein a features for jQuery's Deferred objects are proposed:\ \ When you want to take an action for when ALL Deferred objects are resolved or rejected (ie. not unresolved), you have to wrap a secondary Deferred object around each of them, and ensure that these secondary Deferreds are always resolved. This is because in the multiple Deferreds case where one of the Deferreds is rejected, ""jQuery.when"" IMMEDIATELY FIRES the fail callbacks for its master Deferred, even if some of the Deferreds may still be unresolved at that point.\ \ See: http://stackoverflow.com/questions/5824615/ |
---|
-1, For fear of deferreds turning into a feature creep pit of despair, use the building blocks to make a plugin
Changed June 06, 2011 06:50PM UTC by comment:10
description: | Wherein a features for jQuery's Deferred objects are proposed:\ \ When you want to take an action for when ALL Deferred objects are resolved or rejected (ie. not unresolved), you have to wrap a secondary Deferred object around each of them, and ensure that these secondary Deferreds are always resolved. This is because in the multiple Deferreds case where one of the Deferreds is rejected, ""jQuery.when"" IMMEDIATELY FIRES the fail callbacks for its master Deferred, even if some of the Deferreds may still be unresolved at that point.\ \ See: http://stackoverflow.com/questions/5824615/ → Wherein a features for jQuery's Deferred objects are proposed: \ \ When you want to take an action for when ALL Deferred objects are resolved or rejected (ie. not unresolved), you have to wrap a secondary Deferred object around each of them, and ensure that these secondary Deferreds are always resolved. This is because in the multiple Deferreds case where one of the Deferreds is rejected, ""jQuery.when"" IMMEDIATELY FIRES the fail callbacks for its master Deferred, even if some of the Deferreds may still be unresolved at that point. \ \ See: http://stackoverflow.com/questions/5824615/ |
---|---|
keywords: | 1.7-discuss |
milestone: | 1.next → 1.7 |
resolution: | → wontfix |
status: | open → closed |
Plugin first
Changed September 13, 2012 08:58AM UTC by comment:11
Hello, I stumbled upon the same problem. I've written a modified version of $.when to fix it. (it can be tested at http://jsfiddle.net/LTsLJ/ ):
var // Static reference to slice sliceDeferred = [].slice; $.notBrokenWhen = function( firstParam ) { var args = sliceDeferred.call( arguments, 0 ), i = 0, length = args.length, pValues = new Array( length ), count = length, pCount = length, deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? firstParam : jQuery.Deferred(), promise = deferred.promise(), rejectedFlag; function checkAll() { if (rejectedFlag) { deferred.rejectWith( deferred, args ); } else { deferred.resolveWith( deferred, args ); } } function resolveFunc( i ) { return function( value ) { args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; if ( !( --count ) ) { checkAll(); } }; } function progressFunc( i ) { return function( value ) { pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; deferred.notifyWith( promise, pValues ); }; } function rejectFunc( i ) { return function( value ) { rejectedFlag = true; args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; if ( !( --count ) ) { checkAll(); } } } if ( length > 1 ) { for ( ; i < length; i++ ) { if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { args[ i ].promise().then( resolveFunc(i), rejectFunc(i), progressFunc(i) ); } else { --count; } } if ( !count ) { deferred.resolveWith( deferred, args ); } } else if ( deferred !== firstParam ) { deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); } return promise; }
Changed September 13, 2012 12:21PM UTC by comment:12
And I also made a github project: https://github.com/BiAiB/jquery-fullwhen
Nominating ticket for 1.7 discussion.