-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add RecordArray#filterBy
which contains a live, filtered subset
#3263
Conversation
// `internalRecords`, so we can use the `Ember.computed.filterBy` macro, | ||
// which listens to changes of this property | ||
internalRecords: Ember.computed.mapBy('content', 'record'), | ||
arrangedContent: Ember.computed.filterBy('internalRecords', key, value) |
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.
I'm very unsure about this implementation, since record
on the InternalModel
should be accessed via getRecord()
I guess...
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.
Ember.computed.filterBy('internalRecords') should be filterBy content
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.
I tried that, but then store.all('person').filterBy('name', xxx)
is always an empty array. So I guess observing InternalModel
's and properties on them doesn't work as expected yet ...
@igorT I am not sure about naming the method |
IMO the name it's ok as it is. |
Can we move the ArrayProxy class definition out of the function? It doesn't need to be in its own file (might be nice), but it seems like it could get expensive to create a new class every time a filter is created. |
@fivetanley done |
This method takes the parameters `key` and an optional `value` and returns an updating list of records of the `RecordArray`, which' property value of `key` matches `value`.
Looks good. Should this also be implemented on a |
Thanks @pangratz |
Add `RecordArray#filterBy` which contains a live, filtered subset
Fix failing tests from merging PR #3263
(cherry picked from commit 848fb37)
This change seems problematic to me. First of all, it's a breaking change. Previously a call to let recordArray = getRecordArraySomehow(),
newRecords = recordArray.filterBy('isNew');
if (newRecords.length > 0) {
doSomething();
} After this update, the same code will not run Now before updating to Ember Data 1.13.8 I have to audit all of my usages of Secondly, it seems wrong to override Perhaps the decision to name this method |
Hi @bendemboski. Thanks for bringing up this issue. We talked about this issue in a recent team meeting and it sounds like this is a regression that we want to fix. The current fixing is we will back out the |
I've also faced the same. I'm explicitly converting the relation to an array before filter/sort |
This method takes the parameters
key
and an optionalvalue
andreturns an updating list of records of the
RecordArray
, which'property value of
key
matchesvalue
.This addresses #3171