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

Suggestion to simplify implementation #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,44 @@ collectionView.reload(changes: changes, section: 2, updateData: {
})
```

## API Pagination

```swift

var itemsList: [Video] = []
var deepDiffRefreshVideoList: [Video] = [] {
willSet {

let oldVideos = deepDiffRefreshVideoList
let changes = diff(old: oldVideos, new: newValue)

let exception = tryBlock {
self.collectionView.reload(changes: changes, section: 0, updateData: {
self.itemsList = newValue
}, completion: nil)
}
if let exception = exception {
print(exception as Any)
}

}
}


// in your pagination api callback / simply set the above list

func fetchMainFeedTrending() {
Video.getMostLikeFeed(currentPage).subscribe(
onNext: { [weak self] videos in

self?.itemsList.append(contentsOf: videos)
if let arr = self?.itemsList {
self?.deepDiffRefreshVideoList = arr
}
}
}
```

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.

## How does it work
Expand Down