I want to get object from tableView.rx.itemSelected
and after process it. This method return IndexPath
, so I can map this value. But how to get object at index from the ViewModel
?
struct ViewModel {
var items: Observable<[Item]>
}
Approximate I expect something like this (but this flow is wrong):
tableView.rx.itemSelected
.map { indexPath -> Item in
return viewModel.items.map {$0[indexPath.row]}
}
..subscribe(onNext: { [unowned self] item in
//other actions with Item object
})
.disposed(by: disposeBag)
I showed somewhere this possibility, but cant recollect it. Have you some idea how to do it?
viewModel.items[indexPath.row]
inmap
function? – NetworkviewModel.items
? – Network