Skip to content

Instantly share code, notes, and snippets.

@gfontenot
Last active August 29, 2015 14:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfontenot/683bf0b98a03313b11d9 to your computer and use it in GitHub Desktop.
Save gfontenot/683bf0b98a03313b11d9 to your computer and use it in GitHub Desktop.
// before
let cell = tableView.dequeueReusableCellWithIdentifier("EmployeeCell", forIndexPath: indexPath) as EmployeeCell
if let cellViewModel = viewModel.employeeCellViewModelForIndexPath(indexPath) {
cell.configureWithViewModel(cellViewModel)
}
return cell
// after
let cell = tableView.dequeueReusableCellWithIdentifier("EmployeeCell", forIndexPath: indexPath) as EmployeeCell
let cellViewModel = viewModel.employeeCellViewModelForIndexPath(indexPath)
cellViewModel >>> EmployeeCell.configureWithViewModel(cell)
return cell
// alternate
let cell = tableView.dequeueReusableCellWithIdentifier("EmployeeCell", forIndexPath: indexPath) as EmployeeCell
let cellViewModel = viewModel.employeeCellViewModelForIndexPath(indexPath)
bind(cellViewModel, EmployeeCell.configureWithViewModel(cell))
return cell
// Don't be so clever with the class functions
let cell = tableView.dequeueReusableCellWithIdentifier("EmployeeCell", forIndexPath: indexPath) as EmployeeCell
let cellViewModel = viewModel.employeeCellViewModelForIndexPath(indexPath)
cellViewModel >>> cell.configureWithViewModel
return cell
// Another alternate
let cell = tableView.dequeueReusableCellWithIdentifier("EmployeeCell", forIndexPath: indexPath) as EmployeeCell
viewModel.employeeViewModelForIndexPath(indexPath) >>- cell.configureWithViewModel
return cell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment