Skip to content
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

filterBy unnecessarily removes and re-add items when dependent key changes #9331

Closed
workmanw opened this issue Oct 15, 2014 · 3 comments
Closed

Comments

@workmanw
Copy link

Using {{#each item in filteredItems}} when filteredItems is defined with Ember.computed.filterBy causes contents to unnecessarily be removed and re-added when the dependent key changes, even if the item continues to pass the filter.

Here is a JSBin that illustrates the problem: http://emberjs.jsbin.com/pelidogojiba/2/edit

My use case is simply as shown in the JSBin. My views animate in and the dependent filter key is changing often. Additionally, these particular views are more complex and I'd prefer not to be frequently re-rendering them.


Some after a little bit of digging I discovered the issue is lies here:

this.setValue(
this.callbacks.removedItem.call(this.instanceMeta.context, this.getValue(), c.obj, changeMeta, this.instanceMeta.sugarMeta));
this.setValue(
this.callbacks.addedItem.call(this.instanceMeta.context, this.getValue(), c.obj, changeMeta, this.instanceMeta.sugarMeta));

I believe the reduced_computed does this because it have enough knowledge to know if which operation is necessary. However it seems like there should be a way to do this operation without unnecessary rerendering.

I'm opening to other alternatives, even ones that don't use arrayComputed.

@ahacking
Copy link

Seems to be the same as #4423 and possibly my own reduceComputed issue #9313

There seems to be an entire family of issues with array computed, I just tracked these down as well, #5268, #5558, #5319 which could be of relevance to both our problems.

@cibernox
Copy link
Contributor

I've hit the same wall twice.

I stated the PR #4724 to try to make arrayComputed/reduceComputed properties smarter, but I discovered that the way CP's are implemented is deeply flawed in some senses.

Then I open #4833 as a first step into refactor CPs, but I don't think that is going to make it anytime soon. I think that probably will be delayed until ember 2.0 and when the time comes CP's will be redone from scratch.

@workmanw
Copy link
Author

Yea, there does seem to be several issues relating to arrayComputed/reduceComputed. I think I'll close this infavor of @wagenet's "Cleanup ArrayComputed" issue.

@workmanw workmanw mentioned this issue Oct 16, 2014
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants