Created
January 14, 2021 17:45
-
-
Save thepearl/cd4d9104dcb3bc4ed303624a6c02214e to your computer and use it in GitHub Desktop.
DIFFABLE DS
This file contains hidden or 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: - Observers | |
extension MainView | |
{ | |
func setupObservers() | |
{ | |
// MONITOR search bar textfield keystrokes | |
$keyStroke | |
.receive(on: RunLoop.main) | |
.sink { (keyWordValue) in | |
print(keyWordValue) | |
self.viewModel.keyWordSearch = keyWordValue | |
}.store(in: &cancellables) | |
// DIFFABLE DS | |
viewModel.diffableDataSource = MoviesTableViewDiffableDataSource(tableView: tableView) { (tableView, indexPath, model) -> UITableViewCell? in | |
guard | |
let cell = tableView.dequeueReusableCell(withIdentifier: MovieCell.reuseIdentifier, for: indexPath) as? MovieCell | |
else { return UITableViewCell() } | |
cell.movieObject = model | |
return cell | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment