-
Notifications
You must be signed in to change notification settings - Fork 126
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
Fix sort-by to accept Ember Data relationship #367
Fix sort-by to accept Ember Data relationship #367
Conversation
Thanks for the PR! This seems like it would be a problem for all the helpers, not just sort-by. I'm not exactly sure of a solution off the top of my head but for awaiting the promise before passing into any of the ember-composable-helpers... |
I'm not sure either, it works everywhere else at this point (and worked in Our particular use case is to pass an ember data relationship in using the await helper like
So the promise is actually resolved, but it's passing in a resolved promise and not an array. I couldn't come up with an elegant way to check if something was an already resolved promise and pull the value, but that is probably what is needed (as the helpers, in my opinion, shouldn't be async). |
Feel free to add some more tests to this PR! I was looking at filter and was curious how that would work wrapped in a Promise as well. |
EmberArray isn't iterable and .toArray needs to be called on it to return the original array value.
91b3934
to
0b0d2d4
Compare
You're right! Sorry for the red-herring. The issue isn't the promise, but the |
👍 nice one @jrjohnson, I tried to upgrade |
I've just come across this PR now too. I'm pretty sure #362 is a breaking change for anything ember-data related and not just relationships. The case that broke for me was just a simple:
so I'm not actually accessing anything via a relationship and I have the same regression. @snewcomer if we aren't going ahead with this PR can we at least revert #362 and get a patch release out? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix @jrjohnson! I guess we will punt on the promise thing till later if ppl still want it. I'm assuming you do?
The promise thing was me over-simplifying the problem (incorrectly) and not actually something we need. This fix resolves all of our issues. |
The refactor of
sort-by
in #362 by @snewcomer no longer accepts a resolved Ember Data hasMany relationship as this line throwsarray is not iterable
.