Which rxjava3 retrofit-adapter should we use for Rxjava3
Use the RxJavaRetrofitAdapter library by @akarnokd.
implementation "com.github.akarnokd:rxjava3-retrofit-adapter:3.0.0"
There is now an official Retrofit implementation with version 2.9.0:
Just use the adapter where you create your Retrofit client:
val rxAdapter = RxJava3CallAdapterFactory.create()
retrofit = Retrofit.Builder().baseUrl(baseUrl)
.addConverterFactory(MoshiConverterFactory.create(moshi))
.client(httpClient)
.addCallAdapterFactory(rxAdapter).build()
And include the RxAdapter dependency in your build.gradle
:
implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0'
https://github.com/square/retrofit/blob/master/CHANGELOG.md#version-290-2020-05-20
Also from the documentation:
Unlike the RxJava 1 and RxJava 2 adapters, the RxJava 3 adapter's create() method will produce asynchronous HTTP requests by default. For synchronous requests use createSynchronous() and for synchronous on a scheduler use createWithScheduler(..)