Make add/remove refs based on ref parent states and paths instead of contains? check, keep the valid refs after the to-cursor -> adapt cycle #364
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a proposed change for #360
When a value pointed to by ref changes,
update-refsmakes the ref go through a(adapt (to-cursor ...))process. First we keep the "transformed" ref instead of ignoring it.Second, we make the "whether we have a ref" check based on parent state and path into this state instead of a
contains?check (which for collections comes down toidentical?check).Since a newly added ref is never identical to a "transformed" ref, we end up with duplicate refs pointing to the same parent state and path in the component's
__om_refsarray. Since there are always new refs in the__om_refsarray,refs-changed?always tends to returntrueeven when the parent state didn't change, causingshouldComponentUpdateto always return true whenobservepattern is used.After applying this patch, no duplicate refs are added to the
__om_refsarary. The refs stop updating when no parent state changes occur, causing theref-changed?to eventually returnfalseand makingshouldComponentUpdatebehave in an expected manner whenobserveis used.