您的位置:首頁技術文章
文章詳情頁

android - rxjava2封裝統一取消注冊問題

瀏覽:91日期:2024-02-25 17:47:09

問題描述

我在rxjava1中這么寫沒有問題的,在rxjava2中我應該怎么寫

android - 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...,使用起來很方便。

標簽: java
相關文章:
国产综合久久一区二区三区