Skip to content

Instantly share code, notes, and snippets.

@isaac-weisberg
Last active April 13, 2021 20:11
Show Gist options
  • Save isaac-weisberg/5ef4685b9cb9f296dfa44b6f00b017ed to your computer and use it in GitHub Desktop.
Save isaac-weisberg/5ef4685b9cb9f296dfa44b6f00b017ed to your computer and use it in GitHub Desktop.
class TransactionTableViewModel {
typealias DI = HasTransactionListService
let transactionViewModels: [TransactionCellViewModel]
class NavigationEvents {
let showTransactionAcceptScreen = PublishRelay<String>()
}
let navigation = NavigationEvents()
init(di: DI) {
self.transactionViewModels = di.transactionListService.getTransactionModels()
.map { transactionModel in
let viewModel = TransactionCellViewModelImpl(model: transactionModel)
viewModel.acceptButtonTap
.map { _ in
transactionModel.id
}
.bind(to: navigation.showTransactionAcceptScreen)
.disposed(by: viewModel.disposeBag)
return viewModel
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment