我在rxjava1中这么写没有问题的,在rxjava2中我应该怎么写
光阴似箭催人老,日月如移越少年。
mDisposables.add(mTasksRepository.createAuthorize(rBody) .observeOn(AndroidSchedulers.mainThread()) .subscribe(loginResponse -> { Timber.i("createAuthorizeSuccess"); }, throwable -> { Timber.e("createAuthorizeError"); }));
RxJava 2 features several base classes you can discover operators on:
io.reactivex.Flowable : 0..N flows, supporting Reactive-Streams and backpressure
io.reactivex.Flowable
io.reactivex.Observable: 0..N flows, no backpressure
io.reactivex.Observable
io.reactivex.Single: a flow of exactly 1 item or an error
io.reactivex.Single
io.reactivex.Completable: a flow without items but only a completion or error signal
io.reactivex.Completable
io.reactivex.Maybe: a flow with no items, exactly one item or an error
io.reactivex.Maybe
取消订阅可以试试 RxLifecycle https://github.com/trello/RxL...,使用起来很方便。
RxJava 2 features several base classes you can discover operators on:
io.reactivex.Flowable
: 0..N flows, supporting Reactive-Streams and backpressureio.reactivex.Observable
: 0..N flows, no backpressureio.reactivex.Single
: a flow of exactly 1 item or an errorio.reactivex.Completable
: a flow without items but only a completion or error signalio.reactivex.Maybe
: a flow with no items, exactly one item or an error取消订阅可以试试 RxLifecycle https://github.com/trello/RxL...,使用起来很方便。