Last active
January 30, 2017 21:56
-
-
Save feresr/f11857d45bacc8cb49a58535e39bae14 to your computer and use it in GitHub Desktop.
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
button.setOnClickListener(v -> getData(new DataSubscriber())); | |
public void getData(DataSubscriber subscriber) { | |
Subscription s = apiEndpoints.getData() | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(subscriber); | |
compositeSubscriptions.add(s); | |
} | |
private class DataSubscriber extends Subscriber<Data> { | |
@Override | |
public void onCompleted() { | |
//we are done, yey! | |
} | |
@Override | |
public void onError(Throwable e) { | |
showError("oh no!"); | |
} | |
@Override | |
public void onNext(Data data) { | |
displayData(data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment