I have this seemingly easy use case where in a screen I display data based on sort, and pageIndex, both of which change via UI. So solution is easy
Observable
.combineLatest(sortObservable, pageIndexObservable, Pair::of)
.switchMap(tuple -> getData(tuple.sort, tuple.pageIndex))
However when sort changes, pageIndex should reset to 0.
If I do
Observable
.combineLatest(
sortObservable.doOnNext(__ -> pageIndexObservable.onNext(0),
pageIndexObservable, Pair::of)
.switchMap(tuple -> getData(tuple.sort, tuple.pageIndex))
Then it emits (last sort, 0) and then right away (new sort, 0), id obviously only want to get that (new sort, 0), or somehow ignore that (last sort, 0), i.e. conditionally block pageIndexObservable from emitting.
I dont want to use withLatestFrom because I want pageIndexObservable emits to trigger getData
Thanks