JakeWharton Update to OkHttp 3.11
Use get instead of parse for HttpUrl and MediaType where valid input is always required.
Latest commit ce71d05 Jul 13, 2018
Permalink
..
Failed to load latest commit information.
src Update to OkHttp 3.11 Jul 13, 2018
README.md Update README.md Jul 4, 2018
pom.xml [maven-release-plugin] prepare for next development iteration Mar 14, 2018

README.md

RxJava Adapter

An Adapter for adapting RxJava 1.x types.

Available types:

  • Observable<T>, Observable<Response<T>>, and Observable<Result<T>> where T is the body type.
  • Single<T>, Single<Response<T>>, and Single<Result<T>> where T is the body type.
  • Completable where response bodies are discarded.

Usage

Add RxJavaCallAdapterFactory as a Call adapter when building your Retrofit instance:

Retrofit retrofit = new Retrofit.Builder()
    .baseUrl("https://example.com/")
    .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
    .build();

Your service methods can now use any of the above types as their return type.

interface MyService {
  @GET("/user")
  Observable<User> getUser();
}

By default all reactive types execute their requests synchronously. There are multiple ways to control the threading on which a request occurs:

  • Call subscribeOn on the returned reactive type with a Scheduler of your choice.
  • Use createAsync() when creating the factory which will use OkHttp's internal thread pool.
  • Use createWithScheduler(Scheduler) to supply a default subscription Scheduler.

Download

Download the latest JAR or grab via Maven:

<dependency>
  <groupId>com.squareup.retrofit2</groupId>
  <artifactId>adapter-rxjava</artifactId>
  <version>latest.version</version>
</dependency>

or Gradle:

implementation 'com.squareup.retrofit2:adapter-rxjava:latest.version'

Snapshots of the development version are available in Sonatype's snapshots repository.