First of all sorry for the confusing title, but I actually can't come up with something better (if you do, please edit).
I have an application using Coordinator pattern and RxSwift, so all in all I wan to pass all navigation related stuff to Coordinator, so it can handle navigation logic.
In one view controller I have UITableView
with cells which has UIButton
inside of them. For that case I have a:
actionButton.rx.tap.bind(to: viewModel.chapterAction).disposed(by: disposeBag)
chapterAction
is a PublishSubject<Void>
as it only reflects a button tap, but I need to pass more info to Coordinator, so later I transform this chapterAction
to:
var showChapter: Observable<Chapter> = self.chapterAction.mapTo(self.chapter)
And I assume that up to this point there's nothing wrong with this code, so in View Controller's .bind(to: tableView.rx.items...
I have:
viewModel.showChapter.bind(to: self.viewModel.chapterAction).disposed(by: viewModel.disposeBag)
Since I want to bind this to view controller's viewModel
and later subscribe
in coordinator.
It all works ok, but for some cells I get duplicated taps, why? I've tried putting distinctUntil
, shareReply
, but nothing seems to help my problem and it's not a deterministic one. I suspect some reusing to be involved, but I have no clue where to start looking for this issue...