#14117 closed feature (duplicate)
Allow an array of deferreds as first argument to .when()
Reported by: | Tomalak | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | deferred | Version: | 2.0.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
This is a feature proposal for the Deferred module.
.when()
currently only supports a list of (any number of) individual arguments.
I've been in the situation where I have an array of deferred objects, most commonly a list of pending Ajax calls, which forces me to make use of a construct like jQuery.when.apply(jQuery, array)
in order to pass them to .when()
.
It should be possible to pass an array of deferreds directly to .when()
as its only argument, like this jQuery.when(array)
.
The source code (https://github.com/jquery/jquery/blob/master/src/deferred.js#L93) shows that it would be possible to extend .when()
in that way through a trivial change and without breaking existing functionality.
I've created a pull request that shows the change https://github.com/jquery/jquery/pull/1304
Change History (8)
comment:1 Changed 10 years ago by
Component: | unfiled → deferred |
---|---|
Keywords: | 1.11-discuss added |
Priority: | undecided → low |
Status: | new → open |
comment:2 Changed 10 years ago by
Me too, i also use $.when.apply
a lot, anologue of Q.all/when.all
might be pretty useful, but from jQuery.when doc:
If a single argument is passed to jQuery.when and it is not a Deferred or a Promise, it will be treated as a resolved Deferred and any doneCallbacks attached will be executed immediately.
Although i doubt any code depend on that feature.
@Tomalak, BTW when you submitting a pull request, in addition to source changes and ticket number, you should also have tests that support new functionality and signed CLA, see this site for more information.
comment:3 Changed 10 years ago by
Although i doubt any code depend on that feature.
Why would you doubt that? It's a pretty powerful and common feature. There's a reason that Q.all()
has to exist, and it's because Q()
will accept any single value just like jQuery.when()
.
I don't see how we can even be considering this.
comment:4 Changed 10 years ago by
Resolution: | → duplicate |
---|---|
Status: | open → closed |
Duplicate of #8256.
Sorry dudes...
comment:5 follow-up: 6 Changed 10 years ago by
Keywords: | 1.11-discuss removed |
---|
Sorry, I missed that ticket 18 months ago.
comment:6 Changed 10 years ago by
comment:8 Changed 10 years ago by
I'm not against a $.whenAll
thingy. It's just that we wouldn't be using it in core.
I like this. My main use of when is
$.when.apply
.