android - rxjava2封裝統(tǒng)一取消注冊(cè)問題
問題描述
我在rxjava1中這么寫沒有問題的,在rxjava2中我應(yīng)該怎么寫
問題解答
回答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...,使用起來很方便。
相關(guān)文章:
1. java中返回一個(gè)對(duì)象,和輸出對(duì)像的值,意義在哪兒2. docker網(wǎng)絡(luò)端口映射,沒有方便點(diǎn)的操作方法么?3. mysql - 在不允許改動(dòng)數(shù)據(jù)表的情況下,如何優(yōu)化以varchar格式存儲(chǔ)的時(shí)間的比較?4. docker start -a dockername 老是卡住,什么情況?5. css3 - 純css實(shí)現(xiàn)點(diǎn)擊特效6. apache web server 怎么限制某一個(gè)網(wǎng)站對(duì)服務(wù)器資源的占用?7. javascript - 關(guān)于apply()與call()的問題8. docker - 各位電腦上有多少個(gè)容器啊?容器一多,自己都搞混了,咋辦呢?9. 安全性測(cè)試 - nodejs中如何防m(xù)ySQL注入10. python - pandas dataframe如何對(duì)某列的空數(shù)據(jù)位置進(jìn)行update?update的函數(shù)是自定義的,參數(shù)是同一行的另外兩列數(shù)據(jù)
