Skip to content

Commit 480ddda

Browse files
committed
Updated Readme.
1 parent c926da8 commit 480ddda

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

Readme.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Apple's diffable API requerid models for each object type. If you want use it in
1111
- [Manually](#manually)
1212
- [Usage](#usage)
1313
- [How it work](#usage)
14+
- [Set Content](#set-content)
15+
- [Get Content](#get-content)
1416
- [Mediator](#mediator)
1517
- [Diffable Delegate](#diffable-delegate)
1618
- [Sidebar](#sidebar)
@@ -32,7 +34,7 @@ Once you have your Swift package set up, adding as a dependency is as easy as ad
3234

3335
```swift
3436
dependencies: [
35-
.package(url: "https://github.com/ivanvorobei/SPDiffable.git", .upToNextMajor(from: "2.0.0"))
37+
.package(url: "https://github.com/ivanvorobei/SPDiffable", .upToNextMajor(from: "2.0.0"))
3638
]
3739
```
3840

@@ -98,7 +100,7 @@ class DiffableTableController: SPDiffableTableController {
98100

99101
Now ready model and convert it to views. Time to add content.
100102

101-
#### Apply Content
103+
### Set Content
102104

103105
Now table support models and custom cell provider. You can apply diffable content with animation (or not).
104106
Create content:
@@ -136,11 +138,28 @@ That all. You can each time create new order or count cells and it automatically
136138
If you need something like old function `.reloadData()` in collection and table, look at this method:
137139

138140
```swift
139-
diffableDataSource?.reload(content)
141+
// Reload fully content
142+
diffableDataSource.reload(content)
143+
144+
// Reload only specific items
145+
diffableDataSource.reload(items) // or for 1 item `reload(item)`
146+
140147
```
141148

142149
Changes apply without animation and like deep reload.
143150

151+
### Get Content
152+
153+
You can get index path by item, item by id and many other funcs:
154+
155+
```swift
156+
func item(for indexPath: IndexPath) -> SPDiffableItem? {}
157+
func indexPath(for itemID: SPDiffableItem.Identifier) -> IndexPath? {}
158+
func sections() -> [SPDiffableSection] {}
159+
func section(for index: Int) -> SPDiffableSection? {}
160+
cell<T: UITableViewCell>(_ type: T.Type, for itemID: SPDiffableItem.Identifier) -> T? {}
161+
```
162+
144163
### Mediator
145164

146165
Some methods in diffable data source can't ovveride without custom data source. It solved with mediator delegate. It simple. Next example for table. Set delegate `SPTableDiffableMediator`, all method optional:
@@ -283,7 +302,6 @@ Here provided cells:
283302

284303
Provided only models, becouse for most items using list registration and no need specific cell class.
285304

286-
- `SPDiffableCollectionActionableItem` actionable item for collection view.
287305
- `SPDiffableSideBarItem` menu item in side bar. Support accessories and actions.
288306
- `SPDiffableSideBarButton` button item in side bar. Color of title similar to tint.
289307
- `SPDiffableSideBarHeader` header model for side bar item.

0 commit comments

Comments
 (0)