Changeset
-
An ordered collection of
Changeset
as staged set of changes in the sectioned collection.The order is representing the stages of changesets.
We know that there are combination of changes that crash when applied simultaneously in batch-updates of UI such as UITableView or UICollectionView. The
StagedChangeset
created from the two collection is split at the minimal stages that can be perform batch-updates with no crashes.Example for calculating differences between the two linear collections.
extension String: Differentiable {} let source = ["A", "B", "C"] let target = ["B", "C", "D"] let changeset = StagedChangeset(source: source, target: target) print(changeset.isEmpty) // prints "false"
Example for calculating differences between the two sectioned collections.
See morelet source = [ Section(model: "A", elements: ["😉"]), ] let target = [ Section(model: "A", elements: ["😉, 😺"]), Section(model: "B", elements: ["😪"]) ] let changeset = StagedChangeset(source: sectionedSource, target: sectionedTarget) print(changeset.isEmpty) // prints "false"
Declaration
Swift
public struct StagedChangeset<Collection> where Collection : Collection
-
A set of changes in the sectioned collection.
Changes to the section of the linear collection should be empty.
Notice that the value of the changes represents offsets of collection not index. Since offsets are unordered, order is ignored when comparing two
See moreChangeset
s.Declaration
Swift
public struct Changeset<Collection> where Collection : Collection