Skip to content

Rx support

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

Easily get Observable as a response. Define your response object type as Observable and wasp will create an observable 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