Given two arrays of RandomModelObject
that conform to Codable, Equatable and Hashable I want to calculate a diff between them and animate content changes in a UICollectionView. Having to support iOS 11 made me pick https://github.com/tonyarnold/Differ as a dependency for doing so.
This code:
class ScreenNameCollectionViewDataSource {
var elements: [RandomModelObject] = []
}
extension ScreenNameViewController: ScreenNameViewModelDelegate {
func elementsStoreUpdated() {
collectionView.animateItemAndSectionChanges(oldData: dataSource.elements,
newData: viewModel.blablabla,
updateData: {
dataSource.elements = viewModel.blabla
})
}
}
Produces 2 errors:
Instance method 'animateItemAndSectionChanges(oldData:newData:indexPathTransform:sectionTransform:updateData:completion:)' requires that 'RandomModelObject.Element' conform to 'Equatable'
Instance method 'animateItemAndSectionChanges(oldData:newData:indexPathTransform:sectionTransform:updateData:completion:)' requires that 'RandomModelObject' conform to 'Collection'
The errors don't seem to point me anywhere - Array is a Collection and the model conforms to Equatable. Did I miss anything there?