Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

feat(q): Resolve any promise of array/hash input (q.any) #11809

Closed
wants to merge 1 commit into from

Conversation

candreoliveira
Copy link

Issue reference: #11808

$q is a service inspired by Kris Kowal's Q.

It's usual in frontend applications to make requests to some APIs and based on (at least) a response continue processing the business logic.

For example: An e-commerce almost always needs to receive coupons, vouchers and/or freight discounts. A good architecture will separate responsabilities into distinct micro-services. However, the "perfect" ui could be a single input text. So, we'd use a single input to dispatch 3 requests (3 end-points: coupon, voucher and freight discount) and based on any answer apply the user discount. Hence, we need the ability to manage all requests into a single promise.

The Kris Kowal's Q has the method "any" and I think It's very helpful.

@realityking
Copy link
Contributor

Since Angular is aligning it's promises with ES6, I think it would be better to name it after Promise.race.

@motin
Copy link

motin commented Aug 10, 2015

+1 on including this, albeit called $q.race() as per @realityking's suggestion

@twilczak
Copy link

twilczak commented Sep 9, 2015

I think this feature as implemented is fundamentally different than Promise.race, and probably shouldn't use that name. I don't see a native feature for this in ES6.

@ryanray
Copy link

ryanray commented Sep 16, 2015

+1

@jrencz
Copy link

jrencz commented Sep 25, 2015

Note that .any as implemented here has different semantics than .race as in the Spec.

.race will get rejected after the first one of the promises given to it gets rejected. .all will wait for all of them to get rejected.

This implementation cannot be named .race.

There's #12929 for race

@petebacondarwin
Copy link
Contributor

We are going to implement $q.race() (because it is part of the ES6 Promise spec) and only document how one could implement one's one version of any() (because it is not part of the spec).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants