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

arrayContentDidChange will often call objectAt(0) and objectAt(len - 1) #14843

Closed
hjdivad opened this issue Jan 16, 2017 · 5 comments
Closed

Comments

@hjdivad
Copy link
Member

hjdivad commented Jan 16, 2017

When subclassing MutableArray it is surprising that any mutation can trigger objectAt(0) and objectAt(len -1). This happens because of the checks here for triggering change events for firstObject and lastObject.

This causes some difficulties when dematerializing records in Ember Data, because removing unloaded records from relationships, which is done asynchronously, would cause other records to be rematerialized because the materialization is lazy and the records are retrieved for the sake of this check.

This was reported in #5379 which was never fixed, but was closed in favour of a more limited problem in #5591 which was fixed in #14493.

One possible solution is to trigger changes for firstObject and lastObject only based on the indices of deletions and additions. This will mean that change events will be triggered even in the case of [a,a,b].removeAt(0); which is not the case today.

cc @igorT

@pixelhandler
Copy link
Contributor

@hjdivad just curious do you know if anyone has a PR with a failing test on this issue?

@hjdivad
Copy link
Member Author

hjdivad commented Jan 23, 2017

@pixelhandler i'm not aware of one

@hjdivad
Copy link
Member Author

hjdivad commented Apr 5, 2017

@pixelhandler #15110

8b85116 updates a test to illustrate

dabcbc2 illustrates the suggested fix

@mmun
Copy link
Member

mmun commented Apr 5, 2017

I like the proposed solution.

@bekzod
Copy link
Contributor

bekzod commented Mar 25, 2018

I think this is fixed in #15510 no ?

@rwjblue rwjblue closed this as completed Mar 25, 2018
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

5 participants