Skip to content

Commit d19d35b

Browse files
committed
update readme
1 parent 89fc66f commit d19d35b

File tree

9 files changed

+91
-59
lines changed

9 files changed

+91
-59
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The first thing (found in `Dwifft.swift`) is an algorithm that calculates the di
1616

1717
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.
1818

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).
2020

2121
Even longer version
2222
---
@@ -32,12 +32,12 @@ Why you should use Dwifft
3232
How to get started
3333
---
3434
- 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.
3636
- Then, install Dwifft via cocoapods or carthage or whatever people are using these days.
3737
- Then get to Dwiffing.
3838

3939
Contributing
4040
---
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.
4242

4343
Ok, that's it, there's nothing more here.

docs/Typealiases.html

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,30 @@ <h1>Typealiases</h1>
100100
<li class="item">
101101
<div>
102102
<code>
103-
<a name="/s:6Dwifft34SimpleCollectionViewDiffCalculator"></a>
104-
<a name="//apple_ref/swift/Alias/SimpleCollectionViewDiffCalculator" class="dashAnchor"></a>
105-
<a class="token" href="#/s:6Dwifft34SimpleCollectionViewDiffCalculator">SimpleCollectionViewDiffCalculator</a>
103+
<a name="/s:6Dwifft29SimpleTableViewDiffCalculator"></a>
104+
<a name="//apple_ref/swift/Alias/SimpleTableViewDiffCalculator" class="dashAnchor"></a>
105+
<a class="token" href="#/s:6Dwifft29SimpleTableViewDiffCalculator">SimpleTableViewDiffCalculator</a>
106106
</code>
107107
</div>
108108
<div class="height-container">
109109
<div class="pointer-container"></div>
110110
<section class="section">
111111
<div class="pointer"></div>
112112
<div class="abstract">
113-
<p>See SimpleTableViewDiffCalculator for explanation</p>
113+
<p>Let&rsquo;s say your data model consists of different sections containing different model types. Since
114+
<code><a href="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><a href="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>
114120

115121
</div>
116122
<div class="declaration">
117123
<h4>Declaration</h4>
118124
<div class="language">
119125
<p class="aside-title">Swift</p>
120-
<pre class="highlight"><code><span class="kd">typealias</span> <span class="kt">SimpleCollectionViewDiffCalculator</span> <span class="o">=</span> <span class="kt"><a href="Classes/CollectionViewDiffCalculator.html">CollectionViewDiffCalculator</a></span><span class="o">&lt;</span><span class="kt">AnyHashable</span><span class="p">,</span> <span class="kt">AnyHashable</span><span class="o">&gt;</span></code></pre>
126+
<pre class="highlight"><code><span class="kd">typealias</span> <span class="kt">SimpleTableViewDiffCalculator</span> <span class="o">=</span> <span class="kt"><a href="Classes/TableViewDiffCalculator.html">TableViewDiffCalculator</a></span><span class="o">&lt;</span><span class="kt">AnyHashable</span><span class="p">,</span> <span class="kt">AnyHashable</span><span class="o">&gt;</span></code></pre>
121127

122128
</div>
123129
</div>
@@ -127,30 +133,24 @@ <h4>Declaration</h4>
127133
<li class="item">
128134
<div>
129135
<code>
130-
<a name="/s:6Dwifft29SimpleTableViewDiffCalculator"></a>
131-
<a name="//apple_ref/swift/Alias/SimpleTableViewDiffCalculator" class="dashAnchor"></a>
132-
<a class="token" href="#/s:6Dwifft29SimpleTableViewDiffCalculator">SimpleTableViewDiffCalculator</a>
136+
<a name="/s:6Dwifft34SimpleCollectionViewDiffCalculator"></a>
137+
<a name="//apple_ref/swift/Alias/SimpleCollectionViewDiffCalculator" class="dashAnchor"></a>
138+
<a class="token" href="#/s:6Dwifft34SimpleCollectionViewDiffCalculator">SimpleCollectionViewDiffCalculator</a>
133139
</code>
134140
</div>
135141
<div class="height-container">
136142
<div class="pointer-container"></div>
137143
<section class="section">
138144
<div class="pointer"></div>
139145
<div class="abstract">
140-
<p>Let&rsquo;s say your data model consists of different sections containing different model types. Since
141-
<code><a href="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><a href="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>
147147

148148
</div>
149149
<div class="declaration">
150150
<h4>Declaration</h4>
151151
<div class="language">
152152
<p class="aside-title">Swift</p>
153-
<pre class="highlight"><code><span class="kd">typealias</span> <span class="kt">SimpleTableViewDiffCalculator</span> <span class="o">=</span> <span class="kt"><a href="Classes/TableViewDiffCalculator.html">TableViewDiffCalculator</a></span><span class="o">&lt;</span><span class="kt">AnyHashable</span><span class="p">,</span> <span class="kt">AnyHashable</span><span class="o">&gt;</span></code></pre>
153+
<pre class="highlight"><code><span class="kd">typealias</span> <span class="kt">SimpleCollectionViewDiffCalculator</span> <span class="o">=</span> <span class="kt"><a href="Classes/CollectionViewDiffCalculator.html">CollectionViewDiffCalculator</a></span><span class="o">&lt;</span><span class="kt">AnyHashable</span><span class="p">,</span> <span class="kt">AnyHashable</span><span class="o">&gt;</span></code></pre>
154154

155155
</div>
156156
</div>

docs/docsets/Dwifft.docset/Contents/Resources/Documents/Typealiases.html

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,30 @@ <h1>Typealiases</h1>
100100
<li class="item">
101101
<div>
102102
<code>
103-
<a name="/s:6Dwifft34SimpleCollectionViewDiffCalculator"></a>
104-
<a name="//apple_ref/swift/Alias/SimpleCollectionViewDiffCalculator" class="dashAnchor"></a>
105-
<a class="token" href="#/s:6Dwifft34SimpleCollectionViewDiffCalculator">SimpleCollectionViewDiffCalculator</a>
103+
<a name="/s:6Dwifft29SimpleTableViewDiffCalculator"></a>
104+
<a name="//apple_ref/swift/Alias/SimpleTableViewDiffCalculator" class="dashAnchor"></a>
105+
<a class="token" href="#/s:6Dwifft29SimpleTableViewDiffCalculator">SimpleTableViewDiffCalculator</a>
106106
</code>
107107
</div>
108108
<div class="height-container">
109109
<div class="pointer-container"></div>
110110
<section class="section">
111111
<div class="pointer"></div>
112112
<div class="abstract">
113-
<p>See SimpleTableViewDiffCalculator for explanation</p>
113+
<p>Let&rsquo;s say your data model consists of different sections containing different model types. Since
114+
<code><a href="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><a href="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>
114120

115121
</div>
116122
<div class="declaration">
117123
<h4>Declaration</h4>
118124
<div class="language">
119125
<p class="aside-title">Swift</p>
120-
<pre class="highlight"><code><span class="kd">typealias</span> <span class="kt">SimpleCollectionViewDiffCalculator</span> <span class="o">=</span> <span class="kt"><a href="Classes/CollectionViewDiffCalculator.html">CollectionViewDiffCalculator</a></span><span class="o">&lt;</span><span class="kt">AnyHashable</span><span class="p">,</span> <span class="kt">AnyHashable</span><span class="o">&gt;</span></code></pre>
126+
<pre class="highlight"><code><span class="kd">typealias</span> <span class="kt">SimpleTableViewDiffCalculator</span> <span class="o">=</span> <span class="kt"><a href="Classes/TableViewDiffCalculator.html">TableViewDiffCalculator</a></span><span class="o">&lt;</span><span class="kt">AnyHashable</span><span class="p">,</span> <span class="kt">AnyHashable</span><span class="o">&gt;</span></code></pre>
121127

122128
</div>
123129
</div>
@@ -127,30 +133,24 @@ <h4>Declaration</h4>
127133
<li class="item">
128134
<div>
129135
<code>
130-
<a name="/s:6Dwifft29SimpleTableViewDiffCalculator"></a>
131-
<a name="//apple_ref/swift/Alias/SimpleTableViewDiffCalculator" class="dashAnchor"></a>
132-
<a class="token" href="#/s:6Dwifft29SimpleTableViewDiffCalculator">SimpleTableViewDiffCalculator</a>
136+
<a name="/s:6Dwifft34SimpleCollectionViewDiffCalculator"></a>
137+
<a name="//apple_ref/swift/Alias/SimpleCollectionViewDiffCalculator" class="dashAnchor"></a>
138+
<a class="token" href="#/s:6Dwifft34SimpleCollectionViewDiffCalculator">SimpleCollectionViewDiffCalculator</a>
133139
</code>
134140
</div>
135141
<div class="height-container">
136142
<div class="pointer-container"></div>
137143
<section class="section">
138144
<div class="pointer"></div>
139145
<div class="abstract">
140-
<p>Let&rsquo;s say your data model consists of different sections containing different model types. Since
141-
<code><a href="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><a href="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>
147147

148148
</div>
149149
<div class="declaration">
150150
<h4>Declaration</h4>
151151
<div class="language">
152152
<p class="aside-title">Swift</p>
153-
<pre class="highlight"><code><span class="kd">typealias</span> <span class="kt">SimpleTableViewDiffCalculator</span> <span class="o">=</span> <span class="kt"><a href="Classes/TableViewDiffCalculator.html">TableViewDiffCalculator</a></span><span class="o">&lt;</span><span class="kt">AnyHashable</span><span class="p">,</span> <span class="kt">AnyHashable</span><span class="o">&gt;</span></code></pre>
153+
<pre class="highlight"><code><span class="kd">typealias</span> <span class="kt">SimpleCollectionViewDiffCalculator</span> <span class="o">=</span> <span class="kt"><a href="Classes/CollectionViewDiffCalculator.html">CollectionViewDiffCalculator</a></span><span class="o">&lt;</span><span class="kt">AnyHashable</span><span class="p">,</span> <span class="kt">AnyHashable</span><span class="o">&gt;</span></code></pre>
154154

155155
</div>
156156
</div>

0 commit comments

Comments
 (0)