Skip to content

Instantly share code, notes, and snippets.

@thepearl
Created January 14, 2021 17:45
Show Gist options
  • Save thepearl/cd4d9104dcb3bc4ed303624a6c02214e to your computer and use it in GitHub Desktop.
Save thepearl/cd4d9104dcb3bc4ed303624a6c02214e to your computer and use it in GitHub Desktop.
DIFFABLE DS
//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