Skip to content

Instantly share code, notes, and snippets.

@donnfelker
Forked from eduardostuart/x.java
Last active May 25, 2016 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donnfelker/58f2102806cb5ee76774196df62d87d3 to your computer and use it in GitHub Desktop.
Save donnfelker/58f2102806cb5ee76774196df62d87d3 to your computer and use it in GitHub Desktop.
retrofit2 with rxjava
//[.....]
public void something(String something) {
mSignUpSubscription = mUserService.
create(User.create(something)).
subscribeOn(Schedulers.io()).
observeOn(AndroidSchedulers.mainThread()).
subscribe(new Subscriber<User>() {
@Override
public void onStart() {
Timber.i("Init");
mView.showProgress();
}
@Override
public void onCompleted() {
Timber.d("Done");
mView.hideProgress();
}
@Override
public void onError(Throwable e) {
mView.hideProgress();
// Do something...
}
@Override
public void onNext(User user) {
// ok
}
});
}
//[....]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment