-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RSVP filter with promise that resolves to array #395
Comments
This isn't a thing. Because it tries to work in the same spirit as all |
I would argue that filter is a bit higher level, i.e it would be strange to do RSVP.filter(RSVP.all(array), ...) Much nicer than (supposing RSVP.filter(array.map(function(i){ return RSVP.resolve(i); }), ...) even if arrow functions make this a little prettier: RSVP.filter(array.map(i => RSVP.resolve(i)), ...) I see filter as a "promisified" version of the regular array filter. With my suggestion, The bottom line is that I think However, as I said, it isn't difficult to write a solution yourself. Feel free to close the issue if you still think this is a non-issue. |
I'm not sure why you need this, this is the current behavior. |
Oh, yes, you're right. The thing is that this doesn't work: this.store.find('model').then(models => {
return Ember.RSVP.filter(models, ...);
}) Fails with |
correct, sometime soon enumerables will become ES2015 work around:
|
Great. Thank you. Sorry for my misunderstanding. |
no problem, we should make the switch to iterables sometime during 2.1 or 2.2 of ember |
Along with switching to ES2015 |
I think it would be really beneficial if we allow the first argument of
filter
to be a promise, as well as an array of promises.For example, this is possible:
but this isn't:
Instead, I need to map to an array of promises:
I think the
filter
function should also take a promise that eventually resolves to an array.This would prove especially useful to Ember Data users and async relationships. One can just invoke
filter
asRSVP.filter(model.get('someRelationship'), ...)
. A simpleRSVP.filter(this.store.find(...), ...)
would be nice as well.Of course, in my project I could just create a function that normalizes its arguments and then invokes the regular
filter
func, but I thought I should report in to make this available in core RSVP.The text was updated successfully, but these errors were encountered: