android - rxjava2封裝統(tǒng)一取消注冊(cè)問(wèn)題
問(wèn)題描述
我在rxjava1中這么寫沒(méi)有問(wèn)題的,在rxjava2中我應(yīng)該怎么寫
問(wèn)題解答
回答1: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.Observable: 0..N flows, no backpressure
io.reactivex.Single: a flow of exactly 1 item or an error
io.reactivex.Completable: a flow without items but only a completion or error signal
io.reactivex.Maybe: a flow with no items, exactly one item or an error
取消訂閱可以試試 RxLifecycle https://github.com/trello/RxL...,使用起來(lái)很方便。
相關(guān)文章:
1. html - vue項(xiàng)目中用到了elementUI問(wèn)題2. mysql scripts提示 /usr/bin/perl: bad interpreter3. showpassword里的this 是什么意思?代表哪個(gè)元素4. css3 - border-bottom 的長(zhǎng)度可否超過(guò)盒子的寬度呢?實(shí)現(xiàn)如下圖效果。(我的書(shū)下面的線)5. javascript - windows下如何使用babel,遇到了困惑6. 對(duì)mysql某個(gè)字段監(jiān)控的功能7. css3 - css怎么實(shí)現(xiàn)圖片環(huán)繞的效果8. javascript - 原生canvas中如何獲取到觸摸事件的canvas內(nèi)坐標(biāo)?9. JavaScript事件10. mysql優(yōu)化 - mysql EXPLAIN之后怎么看結(jié)果進(jìn)行優(yōu)化 ?
