Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#10836 closed bug (invalid)

$.when().always() only passes results of rejected promises

Reported by: ryanneufeld Owned by:
Priority: high Milestone: 1.next
Component: deferred Version: 1.7.1rc1
Keywords: Cc:
Blocked by: Blocking:

Description

The behaviour of always() is not what is expected. It get's fired every time, however if one of the promises passed does not resolve, none of the successful data is passed to the callback. Instead a workaround/duck punch of using .pipe() is required.

http://jsfiddle.net/ryanneufeld/xRWDc/7/ -- Current behaviour

http://jsfiddle.net/ryanneufeld/xRWDc/8/ -- duck punched w/ .pipe()

pipe() is serving its purpose here, however always should be getting the resolved values and the rejected values. This would allow for a semantic coding style of rejecting and resolving deferreds while giving developers to write a single function to deal with all the results.

Change History (3)

comment:1 Changed 7 years ago by timmywil

Component: unfileddeferred
Milestone: None1.next
Priority: undecidedhigh
Status: newopen
Version: git1.7.1rc1

Confirmed. Maybe this should be considered for 1.7.1.

comment:2 Changed 7 years ago by jaubourg

Resolution: invalid
Status: openclosed

You can't generalize this behaviour.

The Promise returned by $.when is rejected if and _as soon as_ one of the joined Promises is rejected. This is needed because you can't assume the other Promises will actually get resolved or rejected: http://jsfiddle.net/2LgZG/

What you want is something else than $.when with semantics that involve none of the passed Promises stay in the pending state.

comment:3 Changed 7 years ago by jaubourg

#11162 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.