-
-
Save eduardostuart/1bb0165d96e1ce0946cb9138c23a1327 to your computer and use it in GitHub Desktop.
retrofit2 with rxjava
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//[.....] | |
public void something(String something) { | |
mSignUpSubscription = mUserService. | |
create(User.create(something)). | |
subscribeOn(Schedulers.io()). | |
observeOn(AndroidSchedulers.mainThread()). | |
subscribe(mSignUpSubscriber); | |
} | |
//[....] | |
private Subscriber<User> mSignUpSubscriber = 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