Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the role of RxJava2CallAdapterFactory.create() in retrofit

what is the role of RxJava2CallAdapterFactory.create()...

Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.example.com")
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();
like image 225
Inderjeet Singh Avatar asked Aug 24 '17 05:08

Inderjeet Singh


People also ask

What is Retrofit library?

Retrofit is a type-safe REST client for Android, Java and Kotlin developed by Square. The library provides a powerful framework for authenticating and interacting with APIs and sending network requests with OkHttp. See this guide to understand how OkHttp works.


1 Answers

From description:

A call adapter which uses RxJava 2 for creating observables. Adding this class to Retrofit allows you to return an Observable, Flowable, Single, Completable or Maybe from service methods.

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

Without it you cant describe interface as rx type

like image 141
MakBeard Avatar answered Sep 25 '22 09:09

MakBeard