Skip to content

Instantly share code, notes, and snippets.

@tilltue
Last active June 3, 2019 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tilltue/e5068387d047c774a6bbe2013560e3b8 to your computer and use it in GitHub Desktop.
Save tilltue/e5068387d047c774a6bbe2013560e3b8 to your computer and use it in GitHub Desktop.
Currency Selected ViewModel
struct CurrencySelectedViewModel {
let currencyCellViewModels = BehaviorRelay<[CurrencyCellViewModel]>(value: [])
func selected(cellViewModel: CurrencyCellViewModel) {
}
func cancel() {
}
}
//Presentation Logic
extension CurrencySelectedViewModel {
var listOfCurrencyDatasource: Observable<[AnimatableSectionModel<String,CurrencyCellViewModel>]> {
return self.currencyCellViewModels.map({ (viewModels) -> [AnimatableSectionModel<String,CurrencyCellViewModel>] in
let items = viewModels.map{ viewModel -> CurrencyCellViewModel in
var viewModel = viewModel
viewModel.isSelected = viewModel.currency == self.selected.value
return viewModel
}
return [AnimatableSectionModel(model: "section\(0)", items: items)]
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment