I have this RxJava2 flowable
private val pulseFlowable = Flowable
.interval(200, TimeUnit.MILLISECONDS)
.subscribeOn(Schedulers.computation())
and this subscriber
pulseFlowable
.observeOn(Schedulers.computation())
.subscribe(
object : Subscriber<Long> {
override fun onSubscribe(subscription: Subscription) {
pulseSubscription = subscription
}
override fun onNext(long: Long?) {
onPulse()
}
override fun onError(throwable: Throwable) {
Timber.e("onError")
}
override fun onComplete() {
Timber.d("onComplete")
}
}
)
It produces a MissingBackPressureException
, which I "sort of" understand: Since I'm subscribing and observing on the same scheduler, I initially thought maybe backpressure would not occur, but maybe that was a misconception.
When I change the flowable to
private val pulseFlowable = Flowable
.interval(200, TimeUnit.MILLISECONDS)
.onBackpressureLatest()
.subscribeOn(Schedulers.computation())
I no longer get an exception, but neither is onNext called. Why is that?