DZNEmptyDataSet icon indicating copy to clipboard operation
DZNEmptyDataSet copied to clipboard

Support for Diffable datasource

Open rizwan95 opened this issue 6 years ago • 5 comments

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

rizwan95 avatar Jan 08 '20 10:01 rizwan95

Please, explain. That request is very vague.

dzenbot avatar Jan 09 '20 06:01 dzenbot

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

rizwan95 avatar Jan 09 '20 07:01 rizwan95

@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.

whoyawn avatar May 19 '20 23:05 whoyawn

@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()

rizwan95 avatar May 19 '20 23:05 rizwan95

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.

whoyawn avatar May 19 '20 23:05 whoyawn