Skip to content

Rx support

Orhan Obut edited this page Aug 22, 2015 · 2 revisions

Define your response object type as Observable and wasp will create Observable object in the background and return it.

Rx is optional, to be able to use, add reactive library in your dependencies.

compile 'io.reactivex:rxandroid:1.0.0'

Define your response type as Observable.

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

Get response as observable

service.getUser()
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(observer);
Clone this wiki locally