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.
Checklist
Description
The current code was not correctly leveraging
DifferenceKit
to address moves and updates. In particular, it was not distinguishing changes in content versus changes in the identifier.This code change ensures that the difference identifier is no longer of the whole
Item
, but instead just the hashValue of theItem
(as determined by the implemention ofItem
.)For a visualization of the difference, please see the below gifs (the example iOS code in this repo was slightly modified to illustrate this).
For a clear conceptual example of the correction that this pull request sets out to accomplish, consider if
Item
was the following:And we had to compare the datasource diff of the following lists (being used as datasource updates for a collectionview):
Source:
[(birthName: "Andy", age: 15), (birthName: "Kevin", age: 16)]
Target:
[(birthName: "Kevin", age: 16)]
Without the change in this pull request, we get 2 deletions and 1 insertion (animated as such)
With this change in this PR , we get 1 deletion and 1 update (correctly animated).
Related Issue
N/A
Motivation and Context
The motivation was for a better, and more correct, diff animation.
Impact on Existing Code
None beyond what is described.
Screenshots
Notice the "move" animations that occur in after that do not happen in before
Before:
After: