I am querying database using rxjava jdbc library but using rx1 supported library.
rx.Observable<T> rx1 =Database.from(url, user,password).autoMap(resultType);
I am trying to convert this to
io.reactivex.Observable.fromIterable(BlockingObservable.from(rx1).toIterable());
but it is not working can i get the equivalent code for RX Java 2 . I mean i wanted to return back io.reactivex.Observable<T>
instead of rx.Observable<T>
.
Thank you for your help.
You can use the RxJavaInterop
library to convert between RxJava1 and RxJava2 types. It provides functions to convert between all the different reactive types supported by both versions. In your case, you can convert your RxJava1 Observable
to an RxJava2 Observable
like this:
io.reactivex.Observable<T> rx2 = RxJavaInterop.toV2Observable(rx1);
The library is maintained by the lead developer from the RxJava project itself, so you can be confident it's reliable. Just be sure to use a version of the library from the v0.x branch - more recent versions (3.x) are for converting between RxJava1 and RxJava3.