Rx-Android 库导入 rx.android.plugins 对比 io.reactivex.android.plugins

Rx-Android library import rx.android.plugins vs io.reactivex.android.plugins

我的build.gradle:

compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile "io.reactivex.rxjava2:rxjava:2.1.0"

使用确切的库 External Libraries 在我的一个项目中显示 rxandroid-1.2.0rxandroid-2.0.1,而在另一个项目中只显示后者。

1.2.0 使用 rx.android.schedulers.Scheduler;rx.Observable 兼容,使用时如下:

someRxObservable
  .subscribeOn(Schedulers.io())
  .observeOn(AndroidSchedulers.mainThread())
  .subscribe();
2.0.1 使用的

io.reactivex.Scheduler 不是,因为它不是 rx.Scheduler 的子类。我不确定这是否是依赖项 gradle,因为我希望使用上述 gradle 依赖项下载这两个库。尽管如此,在查看最新版本 2.0.1source code on github 时,它只显示了 io.reactive 解决方案。

io.reactivex 是较新的 RxJava,问题是 AndroidRx 仅适用于 RxJava 的版本 2。解决方法是全面使用 io.reactivex 及其 Observables、Schedulers 和 Subscriptions。