android - rxjava2封裝統一取消注冊問題
問題描述
我在rxjava1中這么寫沒有問題的,在rxjava2中我應該怎么寫
問題解答
回答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...,使用起來很方便。
相關文章:
1. python - linux怎么在每天的凌晨2點執行一次這個log.py文件2. 關于mysql聯合查詢一對多的顯示結果問題3. 實現bing搜索工具urlAPI提交4. MySQL主鍵沖突時的更新操作和替換操作在功能上有什么差別(如圖)5. 數據庫 - Mysql的存儲過程真的是個坑!求助下面的存儲過程哪里錯啦,實在是找不到哪里的問題了。6. windows誤人子弟啊7. mysql優化 - MySQL如何為配置表建立索引?8. 如何用筆記本上的apache做微信開發的服務器9. 我在網址中輸入localhost/abc.php顯示的是not found是為什么呢?10. 冒昧問一下,我這php代碼哪里出錯了???
