提交 74469865 编写于 作者: J Jake Wharton

Add simple usage docs to each adapter.

上级 1ca821af
......@@ -4,6 +4,26 @@ Guava Adapter
An `Adapter` for adapting [Guava][1] `ListenableFuture`.
Usage
-----
Add `GuavaCallAdapterFactory` as a `Call` adapter when building your `Retrofit` instance:
```java
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://example.com/")
.addCallAdapterFactory(GuavaCallAdapterFactory.create())
.build();
```
Your service methods can now use `ListenableFuture` as their return type.
```java
interface MyService {
@GET("/user")
ListenableFuture<User> getUser();
}
```
Download
--------
......
......@@ -4,6 +4,26 @@ Java8 Adapter
An `Adapter` for adapting [Java8][1] `CompletableFuture`.
Usage
-----
Add `Java8CallAdapterFactory` as a `Call` adapter when building your `Retrofit` instance:
```java
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://example.com/")
.addCallAdapterFactory(Java8CallAdapterFactory.create())
.build();
```
Your service methods can now use `CompletableFuture` as their return type.
```java
interface MyService {
@GET("/user")
CompletableFuture<User> getUser();
}
```
Download
--------
......
......@@ -9,6 +9,34 @@ Available types:
* `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:
```java
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.
```java
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
--------
......
......@@ -11,6 +11,33 @@ Available types:
* `Maybe<T>`, `Maybe<Response<T>>`, and `Maybe<Result<T>>` where `T` is the body type.
* `Completable` where response bodies are discarded.
Usage
-----
Add `RxJava2CallAdapterFactory` as a `Call` adapter when building your `Retrofit` instance:
```java
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://example.com/")
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();
```
Your service methods can now use any of the above types as their return type.
```java
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
--------
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册