Kotlin Room RxJava-onNext()在FlowableSubscriber中调用一次

Kotlin Room RxJava-onNext()在FlowableSubscriber中调用一次,kotlin,rx-java,rx-java2,android-room,Kotlin,Rx Java,Rx Java2,Android Room,以下是我的FlowableSubscriber代码 fun getFlowableSubscriber(): FlowableSubscriber<List<Incoming>>{ return object : FlowableSubscriber<List<Incoming>> { override fun onComplete() { log("onComplete") }

以下是我的FlowableSubscriber代码

fun getFlowableSubscriber(): FlowableSubscriber<List<Incoming>>{
    return object : FlowableSubscriber<List<Incoming>> {
        override fun onComplete() {
            log("onComplete")
        }

        override fun onSubscribe(subscription: Subscription) {
            log("onSubscribe")
            this@IncomingFragment.subscription = subscription
            subscription.request(Long.MAX_VALUE)

        }

        override fun onNext(items: List<Incoming>) {
            log("onNext item size is ${items.size}")      
        }

        override fun onError(t: Throwable?) {
            log("onError $t")

        }
    }
}
问题是
onNext()
只运行一次,我希望每次调用
onResume()
时都会触发它。但是
subscription.request()
似乎只工作一次。
我正在使用这个房间。

我想你应该考虑使用LiviaDATA,因为它用10%来完成。complexity@EpicPandaForce是的,就我而言,首先选择Rx是一个很大的错误。你不能重复使用
FlowableSubscriber
Subscription
泄漏到停止/恢复中。一旦调用了
cancel()
,就不会发出进一步的数据,因此resume中的
请求将不起任何作用。你必须用新的
订户重新订阅源代码
@akarnokd谢谢,这正是我解决问题的方法。
 override fun onResume() { 
        if (::subscription.isInitialized){
            subscription.request(Long.MAX_VALUE) 
        }
        super.onResume()
    }


    override fun onStop() { 
        subscription.cancel()
        super.onStop()
    }