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-refs
makes 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_refs
array. Since there are always new refs in the__om_refs
array,refs-changed?
always tends to returntrue
even when the parent state didn't change, causingshouldComponentUpdate
to always return true whenobserve
pattern is used.After applying this patch, no duplicate refs are added to the
__om_refs
arary. The refs stop updating when no parent state changes occur, causing theref-changed?
to eventually returnfalse
and makingshouldComponentUpdate
behave in an expected manner whenobserve
is used.