Compute differences between two sequences of elements.
These can be passed to updateSection
extensions to animate transitions.
Example
// Update self.items array of view models
let previous: [ViewModel] = self.items
self.items = model.currentViewModels()
let diff = previous.diff(self.items)
// Animate changes to view models array
self.tableView.beginUpdates()
self.tableView.updateSection(0, diff: diff)
self.tableView.endUpdates()
Installation
ElementDiff is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "ElementDiff"
Releases
- 0.8.0 - 2019-06-10 - Swift 5.1 support in podspec
- 0.7.0 - 2018-10-02 - Swift 4.2 support
- 0.6.0 - 2018-04-23 - Throw error for non-unique ids
- 0.5.0 - 2017-06-23 - Add
fatalError
for non-unique ids - 0.4.0 - 2016-12-06 - Swift 3 support
- 0.3.0 - 2016-09-03 - Remove
reloadRowsAtIndexPaths
- 0.2.1 - 2016-03-04 - Make ElementDiff struct fields vars
- 0.2.0 - 2015-12-22 - Allow for using custom identifier
- 0.1.0 - 2015-12-12 - Initial public release
- 0.0.0 - 2015-07-29 - Initial private version for project at Q42
License & Credits
ElementDiff is written by Tom Lokhorst of Q42 and available under the MIT license, so fee free to use it in commercial and non-commercial projects.