In this article, we’re going to create a generic and reusable implementation of
UICollectionViewDiffableDataSource in MVVM. Hope you’re excited!
UICollectionViewDiffableDataSource is a declarative API for
UICollectionView data source released by Apple in iOS 13.
It sets an alternative to the old
UICollectionViewDataSource — which provides us with delegate methods to determine the number of sections & cells and cell configuration based on our data set, and methods to remove and insert cells into the collection view. This approach isn’t always safe as things can often go wrong on our side; the data may not always be there at the collection view’s index path or we can miscalculate the ranges when inserting or removing cells at an index path. …