Skip to main content

Bug Tracker

Side navigation

#8256 closed enhancement (wontfix)

Opened February 12, 2011 12:02AM UTC

Closed February 12, 2011 12:18AM UTC

Last modified July 09, 2013 02:08PM UTC

$.when should accept an array of promises

Reported by: me@adamluikart.com Owned by:
Priority: low Milestone: 1.next
Component: deferred Version: 1.5
Keywords: Cc:
Blocked by: Blocking:
Description

This would be super nice, because $.when.apply($, promisesArr) looks converugly.

I'm not sure if there's a case where you'd want an array to be treated like a resolved Deferred that this would break – if so, maybe you could peek at the first element to see if it's a promise?

Attachments (0)
Change History (10)

Changed February 12, 2011 12:18AM UTC by jaubourg comment:1

description: This would be super nice, because $.when.apply($, promisesArr) looks ugly. \ \ I'm not sure if there's a case where you'd want an array to be treated like a resolved Deferred that this would break – if so, maybe you could peek at the first element to see if it's a promise?This would be super nice, because $.when.apply($, promisesArr) looks converugly. \ \ I'm not sure if there's a case where you'd want an array to be treated like a resolved Deferred that this would break – if so, maybe you could peek at the first element to see if it's a promise?
resolution: → wontfix
status: newclosed

This would break things like:

$.when( [ 1, 2, 3 ] );

Inspecting the first element only wouldn't make sense either.

You can easily code your own whenArray functionality if and when you're tired of apply:

jQuery.whenArray = function( array ) {
    return jQuery.when.apply( this, array );
};

A "deep" when could be nice though but that's another conversation.

Changed February 12, 2011 12:20AM UTC by jitter comment:2

component: unfiledcore
priority: undecidedlow

Changed September 19, 2011 01:53PM UTC by rwaldron comment:3

#10307 is a duplicate of this ticket.

Changed September 19, 2011 01:53PM UTC by rwaldron comment:4

component: coredeferred

Changed September 28, 2011 06:13PM UTC by rwaldron comment:5

#10367 is a duplicate of this ticket.

Changed January 14, 2012 12:06AM UTC by rwaldron comment:6

#11172 is a duplicate of this ticket.

Changed January 14, 2012 12:08AM UTC by rwaldron comment:7

So, considering the number of requests for this feature, I'm wondering if we should consider adding support?

Changed January 14, 2012 10:35AM UTC by jaubourg comment:8

Replying to [comment:7 rwaldron]:

So, considering the number of requests for this feature, I'm wondering if we should consider adding support?

If we do so, then we add the two liner given above. I think people are being lazy here and refuse to aknowledge the inconsistencies implied as long as "it works" for them.

Changed January 14, 2012 03:54PM UTC by rwaldron comment:9

@jaubourg TBH, I'm willing to go with whatever you recommend, but I also still think it's feature creep/bloat

Changed July 09, 2013 02:08PM UTC by rwaldron comment:10

#14117 is a duplicate of this ticket.