我有这个RxJava2 flowable
private val pulseFlowable = Flowable
.interval(200, TimeUnit.MILLISECONDS)
.subscribeOn(Schedulers.computation())
和该订户
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")
}
}
)
它产生一个MissingBackPressureException
,我“有点”理解:由于我在同一调度程序上进行订阅和观察,因此我最初认为可能不会出现背压,但这也许是一个误解。 >
当我将流通量更改为
private val pulseFlowable = Flowable
.interval(200, TimeUnit.MILLISECONDS)
.onBackpressureLatest()
.subscribeOn(Schedulers.computation())
我不再遇到异常,但是onNext都没有被调用。为什么会这样?