Skip to content
This repository was archived by the owner on Dec 5, 2022. It is now read-only.

Commit 67c1fca

Browse files
committed
Update README
1 parent 0a83ef7 commit 67c1fca

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,16 @@ Changes to `DataSource` can be animated by using batch update, as guided in [Bat
7474

7575
Since `Change` returned by `DeepDiff` follows the way batch update works, animating `DataSource` changes is easy.
7676

77+
For safety, update your data source model inside `updateData` to ensure synchrony inside `performBatchUpdates`
78+
7779
```swift
7880
let oldItems = items
79-
items = DataSet.generateNewItems()
80-
let changes = diff(old: oldItems, new: items)
81+
let newItems = DataSet.generateNewItems()
82+
let changes = diff(old: oldItems, new: newItems)
8183

82-
collectionView.reload(changes: changes, section: 2, updateData: { // update data source model })
84+
collectionView.reload(changes: changes, section: 2, updateData: {
85+
self.items = newItems
86+
})
8387
```
8488

8589
Take a look at [Demo](https://github.com/onmyway133/DeepDiff/tree/master/Example/DeepDiffDemo) where changes are made via random number of items, and the items are shuffled.

0 commit comments

Comments
 (0)