Skip to content

Instantly share code, notes, and snippets.

@feresr
Last active Jan 30, 2017
Embed
What would you like to do?
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