Last active
November 30, 2020 09:26
-
-
Save eilonkr/f38b06193568a0c183d3e34d77a48240 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Setup Logic | |
extension CollectionViewModel { | |
private func cellProvider(_ collectionView: UICollectionView, indexPath: IndexPath, item: Item) -> UICollectionViewCell? { | |
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath) as! CellType | |
cell.provide(item) | |
return cell | |
} | |
public func makeDataSource() -> DataSource { | |
guard let collectionView = collectionView else { fatalError("CollectionView isn't here :(") } | |
let dataSource = DataSource(collectionView: collectionView, cellProvider: cellProvider) | |
self.dataSource = dataSource | |
return dataSource | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment