Dwifft v0.9 Release Notes
Release Date: 2018-09-18 // about 5 years ago-
No data yet ๐
You can check the official repo
Previous changes from v0.6
-
The Good News
๐ One of the most common feature requests since Dwifft launched has been the ability to more easily manage
UITableView
/UICollectionView
s with multiple sections. I am beyond pleased to announce that Dwifft 0.6 gains this feature! This is done by modeling your data with a new struct titledSectionedValues<Section, Value>
.SectionedValues
is akin to an ordered dictionary - it contains an array of tuples, where the first element in the tuple represents the section itself, and the second element is an array of elements that should be contained at that section. If you were mapping this to, say, the Contacts app, you might imagine eachSection
would be a letter of the alphabet, and theValue
s for eachSection
would be the contacts whose name started with that letter.SectionedValues
can be a little annoying to construct, so they have some convenience initializers that can make that easier - you should read their documentation for more info.โก๏ธ
TableViewDiffCalculator
andCollectionViewDiffCalculator
have been updated to reflect this. Instead of setting theirrows
property to an array, you now set theirsectionedValues
property to a, you guessed it, instance ofSectionedValues
. This will now make calls toinsertSections
anddeleteSections
as well asinsert{Rows|Items}
anddelete{Rows|Items}
on your view. If you'd like to see this all in action, look at the example app, which has been updated to use all the new APIs.There's some other good stuff in this release too. Dwifft is now tested with SwiftCheck, which yields much stronger guarantees around the correctness of the underlying diff algorithm. Dwifft 0.6 is also much faster and memory-efficient (like, an order of magnitude). I've also really beefed up the documentation - it's now autogenerated with jazzy and I'm pleased to say has 100% documentation coverage.
๐ All of this was really hard to accomplish, especially in a way that didn't have garbage performance. I don't know of another diffing library that supports multi-section changes! I want to thank everyone who gave their feedback on the design and implementation.
The Bad News
๐ Dwifft 0.6 has breaking changes. Sorry not sorry, this is a pre-1.0 library (even though it's like 2 years old) and I'm still settling on its shape. Notably, I have removed or slightly changed several types and methods.
TableViewDiffCalculator
andCollectionViewDiffCalculator
now use the aforementionedsectionedValues
property instead ofrows
. If you would like the old behavior back, for the purposes of migrating, useSingleSectionTableViewDiffCalculator
/SingleSectionCollectionViewDiffCalculator
, which behave ~identically to howTableViewDiffCalculator
/CollectionViewDiffCalculator
used to work.- ๐ Array.diff(otherArray) has been deprecated (extensions like that are bad). To do this you should now call
Dwifft.diff(array1, array2)
instead, which behaves exactly the same way. - ๐ The
Diff
struct has been removed - calls todiff
now just return an array ofDiffStep
s (Diff
was just a thin wrapper around this array, and is no longer necessary). - ๐ The LCS methods have been removed (if you don't know what I'm talking about, this doesn't affect you). These were mostly just useful for bootstrapping the original diff algorithm. If you were using them for something (I sort of doubt anyone was), drop me a line and we can spin them off into a separate library.
๐ If you're having trouble migrating, drop me a line and I'll help.