public final class RxJavaCallAdapterFactory extends CallAdapter.Factory
Adding this class to Retrofit allows you to return an Observable, Single,
or Completable from service methods.
interface MyService {
@GET("user/me")
Observable<User> getUser()
}
There are three configurations supported for the Observable or Single type
parameter:
Observable<User>) calls onNext with the deserialized body
for 2XX responses and calls onError with HttpException for non-2XX responses and
IOException for network errors.Observable<Response<User>>) calls onNext
with a Response object for all HTTP responses and calls onError with
IOException for network errorsObservable<Result<User>>) calls onNext with a
Result object for all HTTP responses and errors.
Note: Support for Single and Completable is experimental and subject
to backwards-incompatible changes at any time since both of these types are not considered
stable by RxJava.
| Modifier and Type | Method and Description |
|---|---|
static RxJavaCallAdapterFactory |
create()
Returns an instance which creates synchronous observables that do not operate on any scheduler
by default.
|
static RxJavaCallAdapterFactory |
createAsync()
Returns an instance which creates asynchronous observables.
|
static RxJavaCallAdapterFactory |
createWithScheduler(rx.Scheduler scheduler)
Returns an instance which creates synchronous observables that
subscribe on
scheduler by default. |
CallAdapter<?,?> |
get(Type returnType,
Annotation[] annotations,
Retrofit retrofit) |
getParameterUpperBound, getRawTypepublic static RxJavaCallAdapterFactory create()
public static RxJavaCallAdapterFactory createAsync()
public static RxJavaCallAdapterFactory createWithScheduler(rx.Scheduler scheduler)
scheduler by default.@Nullable public CallAdapter<?,?> get(Type returnType, Annotation[] annotations, Retrofit retrofit)
get in class CallAdapter.FactoryCopyright © 2020 Square, Inc.. All rights reserved.