$.when should always be synchronous when possible #3100
|
@gibson042 Did we discuss this before? Did we want to make |
|
It's important to realize that I also disagree with Promises/A+ 2.2.4, but that is insufficient justification to abandon compatibility which has been demanded for so long. |
|
I know @gibson042 has rightly railed about this several times, I'm too lazy to dig it up. In the pre-3.0 implementation there was a special case of "If there is only one argument, and it is a Edit: What @gibson042 said. |
I answer myself here - no it is not. Discuss this with @gibson042 on irc, it seems there is motivation to make this call always async regardless of the arguments, opened a different issue for that - #3102 |
IIC, jQuery 3.0 will have
thenbe A+ compatible in that callbacks are always executed out of context (e.g withsetTimeout), whiledonewill continue to be executed synchronously whenever possible (eager).I was double checking that
$.whenkept the eager behavior and discovered that it does, unless there's a single argument:I was hope to get ABCD, given that the promised is already resolved when the
doneare called, and dreaded ADBC if$whenwas no longer eager. I get worse though. Console is ACDB, which is not acceptable;$.when(p)and$.when(p, p)should behave the exact same way.FWIW, I personally disagree with Promise/A+'s rule 2.2.4 and I hope jQuery keeps all behavior eager (except for
thento comply with A+) and gives us an eager version ofthen(could bepipe, but with the correct semantics for callbacks return values).I did not investigate any further, but it looks related to #3059.