dzenbot / DZNEmptyDataSet

A drop-in UITableView/UICollectionView superclass category for showing empty datasets whenever the view has no content to display
https://www.cocoacontrols.com/controls/dznemptydataset
MIT License
12.09k stars 1.73k forks source link

Support for Diffable datasource #452

Open rizwan95 opened 4 years ago

rizwan95 commented 4 years ago

It would be great if the support for diffable datasource is given! @dzenbot

dzenbot commented 4 years ago

Please, explain. That request is very vague.

rizwan95 commented 4 years ago

Apple introduced Diffable datasources for TableViews and collectionviews from iOS 13 onwards. Instead of UITableViewDataSource, DiffableDatasource can be used. Which means that we should not explicitly call reloadData or performBatch updates. The diffable datasource will take care of things.

So we need support for the developers who use diffable datasourece.

WWDC link : https://developer.apple.com/videos/play/wwdc2019/220

@dzenbot

whoyawn commented 4 years ago

@rizwan95 UITableViewDiffableDataSource conforms to UITableViewDataSource. It's still possible to use. Just call tableView.reloadEmptyDataSet() after calling apply(snapshot:animatingDifferences:) and implement emptyDataSetShouldDisplay(_: UIScrollView!) to check your data models.

rizwan95 commented 4 years ago

@whoyawn : Yes, tableView.reloadEmptyDataSet() works, but when a diffable data source is used, we are not supposed to call tableView.reloadData() according to Apple. So, does this affect ``` reloadEmptyDataSet()

whoyawn commented 4 years ago

The comment above reloadEmptyDataSet() says

/* Reloads the empty dataset content receiver. @discussion Call this method to force all the data to refresh. Calling -reloadData is similar, but this forces only the empty dataset to reload, not the entire table view or collection view. /

So it shouldn't call the reloadData() nor do any heavy table view related operations at all. @dzenbot Correct me if I'm wrong.