Rxjava emit only if a condition is met
I have a polling function that is mapped to 3 different states
private fun pollFromApi(): Observable {
return Observable.interval(3L, TimeUnit.SECONDS,
schedulerProvider.io())
.startWith(0L)
.flatMap {
api.getCall().toObservable()
}
.map {
when {
condition1 -> State1 // convert response to State1
condition2 -> State2 // convert response to State2
condition3 -> State3 // convert response...