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. javascript - js中向下取整2. 對mysql某個字段監控的功能3. showpassword里的this 是什么意思?代表哪個元素4. mysql優化 - mysql EXPLAIN之后怎么看結果進行優化 ?5. html - vue項目中用到了elementUI問題6. html5 - 求詳解h5 video事件監聽7. javascript - 原生canvas中如何獲取到觸摸事件的canvas內坐標?8. JavaScript事件9. mysql scripts提示 /usr/bin/perl: bad interpreter10. python - 為什么正常輸出中文沒有亂碼,zip函數之后出現中文編程unicode編碼的問題,我是遍歷輸出的啊。
