doOnUnsubscribe不在Observable线程上调用

时间:2016-08-22 21:33:13

标签: android rx-java rx-android

目前<init-param> <param-name>appUrl</param-name> <param-value>${app.url}</param-value> </init-param> 总是在doOnTerminate(...)主题上调用,IO Scheduler doOnUnsubscribe(...)上调用UI thread Scheduler

fun <T> withTransaction(sourceObservable: Observable<T>): Observable<T> {
    ...
    return Observable.empty<T>()
            .doOnCompleted { startTransaction() }
            .mergeWith(sourceObservable)
            .doOnNext { setTransactionSuccessful() }
            .doOnTerminate(...) // called on RxIoScheduler-2 thread
            .doOnUnsubscribe(...) // called on main thread
            .subscribeOn(Schedulers.io())
            .observeOn(Schedulers.io()) // didn't help
}

如何强制在IO线程上执行doOnUnsubscribe?

0 个答案:

没有答案