You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ The first thing (found in `Dwifft.swift`) is an algorithm that calculates the di
16
16
17
17
The second thing (found in `Dwifft+UIKit.swift`) is a series of diff calculators for `UITableView`s and `UICollectionView`s. Let's say you have a `UITableView` that's backed by a simple array of values (like a list of names, e.g. `["Alice", "Bob", "Carol"]`. If that array changes (maybe Bob leaves, and is replaced by Dave, so our list is now `["Alice, "Carol", "Dave"]`), we'll want to update the table. The easiest way to do this is by calling `reloadData` on it. This has a couple of downsides: the transition isn't animated, and it'll cause your user to lose their scroll position if they've scrolled the table. The nicer way is to use the `insertRowsAtIndexPaths:withRowAnimation` and `deleteRowsAtIndexPaths:withRowAnimation` methods on `UITableView`, but this requires you to figure out which index paths have changed in your array (in our example, you'd have to figure out that the row at index 1 should be removed, and a new row should be inserted at index 2 should then be added). If only we had a way to diff the previous value of our array with it's new value. Wait a minute.
18
18
19
-
When you wire up a `TableViewDiffCalculator` to your `UITableView` (or a `CollectionViewDiffCalculator` to your `UICollectionView`, it'll _automatically_ calculate diffs and trigger the necessary animations on it whenever you change its `sectionedValues` property. Neat, right? Notably, as of Dwifft 0.6, Dwifft will also figure out _section_ insertions and deletions, as well as how to efficiently insert and delete rows across different sections, which is just so massively useful if you have a multi-section table. If you're currently using a <0.6 version of Dwifft and want to do this, read the [0.6 release notes](TODO).
19
+
When you wire up a `TableViewDiffCalculator` to your `UITableView` (or a `CollectionViewDiffCalculator` to your `UICollectionView`, it'll _automatically_ calculate diffs and trigger the necessary animations on it whenever you change its `sectionedValues` property. Neat, right? Notably, as of Dwifft 0.6, Dwifft will also figure out _section_ insertions and deletions, as well as how to efficiently insert and delete rows across different sections, which is just so massively useful if you have a multi-section table. If you're currently using a <0.6 version of Dwifft and want to do this, read the [0.6 release notes](https://github.com/jflinter/Dwifft/releases/tag/0.6).
20
20
21
21
Even longer version
22
22
---
@@ -32,12 +32,12 @@ Why you should use Dwifft
32
32
How to get started
33
33
---
34
34
- First, you should take a look at the example app, to get a feel for how Dwifft is meant to be used.
35
-
- Next, you should just sit down and read the [entire documentation](TODO) - it will take you <10 minutes, and you'll leave knowing everything there is to know about Dwifft.
35
+
- Next, you should just sit down and read the [entire documentation](https://jackflintermann.com/Dwifft) - it will take you <10 minutes, and you'll leave knowing everything there is to know about Dwifft.
36
36
- Then, install Dwifft via cocoapods or carthage or whatever people are using these days.
37
37
- Then get to Dwiffing.
38
38
39
39
Contributing
40
40
---
41
-
Contributions are welcome, with some caveats - please read the [contributing guidelines](TODO) before opening a PR to avoid wasting both our time.
41
+
Contributions are welcome, with some caveats - please read the [contributing guidelines](https://github.com/jflinter/Dwifft/blob/master/CONTRIBUTING.md) before opening a PR to avoid wasting both our time.
<p>See SimpleTableViewDiffCalculator for explanation</p>
113
+
<p>Let’s say your data model consists of different sections containing different model types. Since
114
+
<code><ahref="Structs/SectionedValues.html">SectionedValues</a></code> requires a uniform type for all of its rows, this can be a clunky situation. You
115
+
can address this in a couple of ways. The first is to define a custom enum that encompasses all of the
116
+
things that <em>could</em> be in your data model - if section 1 has a bunch of <code>String</code>s, and section 2 has a bunch
117
+
of <code>Int</code>s, define a <code>StringOrInt</code> enum that conforms to <code>Equatable</code>, and fill the <code><ahref="Structs/SectionedValues.html">SectionedValues</a></code>
118
+
that you use to drive your DiffCalculator up with those. Alternatively, if you are lazy, and your
119
+
models all conform to <code>Hashable</code>, you can use a SimpleTableViewDiffCalculator instead.</p>
<p>Let’s say your data model consists of different sections containing different model types. Since
141
-
<code><ahref="Structs/SectionedValues.html">SectionedValues</a></code> requires a uniform type for all of its rows, this can be a clunky situation. You
142
-
can address this in a couple of ways. The first is to define a custom enum that encompasses all of the
143
-
things that <em>could</em> be in your data model - if section 1 has a bunch of <code>String</code>s, and section 2 has a bunch
144
-
of <code>Int</code>s, define a <code>StringOrInt</code> enum that conforms to <code>Equatable</code>, and fill the <code><ahref="Structs/SectionedValues.html">SectionedValues</a></code>
145
-
that you use to drive your DiffCalculator up with those. Alternatively, if you are lazy, and your
146
-
models all conform to <code>Hashable</code>, you can use a SimpleTableViewDiffCalculator instead.</p>
146
+
<p>See SimpleTableViewDiffCalculator for explanation</p>
<p>See SimpleTableViewDiffCalculator for explanation</p>
113
+
<p>Let’s say your data model consists of different sections containing different model types. Since
114
+
<code><ahref="Structs/SectionedValues.html">SectionedValues</a></code> requires a uniform type for all of its rows, this can be a clunky situation. You
115
+
can address this in a couple of ways. The first is to define a custom enum that encompasses all of the
116
+
things that <em>could</em> be in your data model - if section 1 has a bunch of <code>String</code>s, and section 2 has a bunch
117
+
of <code>Int</code>s, define a <code>StringOrInt</code> enum that conforms to <code>Equatable</code>, and fill the <code><ahref="Structs/SectionedValues.html">SectionedValues</a></code>
118
+
that you use to drive your DiffCalculator up with those. Alternatively, if you are lazy, and your
119
+
models all conform to <code>Hashable</code>, you can use a SimpleTableViewDiffCalculator instead.</p>
<p>Let’s say your data model consists of different sections containing different model types. Since
141
-
<code><ahref="Structs/SectionedValues.html">SectionedValues</a></code> requires a uniform type for all of its rows, this can be a clunky situation. You
142
-
can address this in a couple of ways. The first is to define a custom enum that encompasses all of the
143
-
things that <em>could</em> be in your data model - if section 1 has a bunch of <code>String</code>s, and section 2 has a bunch
144
-
of <code>Int</code>s, define a <code>StringOrInt</code> enum that conforms to <code>Equatable</code>, and fill the <code><ahref="Structs/SectionedValues.html">SectionedValues</a></code>
145
-
that you use to drive your DiffCalculator up with those. Alternatively, if you are lazy, and your
146
-
models all conform to <code>Hashable</code>, you can use a SimpleTableViewDiffCalculator instead.</p>
146
+
<p>See SimpleTableViewDiffCalculator for explanation</p>
0 commit comments