android - rxjava2封裝統(tǒng)一取消注冊問題
問題描述
我在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. css - 關(guān)于偽類背景問題2. html - 移動端radio無法選中3. apache - 怎么給localhost后面默認(rèn)加上8080端口4. html5 - 如何實(shí)現(xiàn)圖中的刻度漸變效果?5. windows-7 - Win7中Vmware Workstatoin與Xampp中Apache服務(wù)器端口沖突?6. mysql - 數(shù)據(jù)庫建字段,默認(rèn)值空和empty string有什么區(qū)別 1107. python - 用scrapy-splash爬取網(wǎng)站 為啥iframe下的內(nèi)容沒有被返回8. 關(guān)于Navicat連接到mysql,我改了root的密碼后,Navicat連接報(bào)錯1862?9. mysql起不來了,為什么?10. mysql里show full processlist,進(jìn)程很少
