ra1028 / DiffableDataSources

💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.
https://ra1028.github.io/DiffableDataSources
Apache License 2.0
853 stars 69 forks source link

[WIP] Completion Block for CollectionView and TableView DiffableDatasources #10

Closed serjooo closed 4 years ago

serjooo commented 4 years ago

Checklist

Description

This library provides a back port to UITableViewDiffableDataSource, UICollectionViewDiffableDataSource, and NSCollectionViewDiffableDataSource and tries to stay as close to the API as possible.

However, one part of the API is missing for UICollectionView and UITableView that does not exist for NSCollectionView which is the Completio block of applying the difference.

UIKIt: apply(_:animatingDifferences:completion:) AppKit: applySnapshot:animatingDifferences:

However, to achieve this we would need to change the internals of DifferenceKit on the reload method to accept a completion block and call it once it is done applying the difference.

Motivation and Context

By providing a completion on apply method, the API will be exactly as Apple's APIs.

Impact on Existing Code

As Apple's API completion block is optional, the function parameter could default to nil and this will not effect the client code and will not cause any breaking changes.

serjooo commented 4 years ago

As discussed with @ra1028 on the following PR adding completion block on DifferenceKit is not an option marking this PR as irrelevant.

ra1028 commented 4 years ago

@serjooo Thanks for your PR. I don't prefer adding a completion block to DIfferenceKit, but I think possible it in DiffableDataSources because it's closer to the UI layer. I'll try to implement completion block with CATransaction to be exactly as official DiffableDataSource API.