I'm starting to learn the advantages of RxJava, and I would like someone to give me a hand to get more to the point.
The issue would be to modify this code made with listeners:
public void getData( final OnResponseListener listener ){
if(data!=null && !data.isEmpty()){
listener.onSuccess();
}
else{
listener.onError();
}
}
Listener:
public interface OnResponseListener {
public void onSuccess();
public void onError();
}
And the one who listens:
object.getData( new OnResponseListener() {
@Override
public void onSuccess() {
Log.w(TAG," on success");
}
@Override
public void onError() {
Log.e(TAG," on error");
}
});
How to do this with observables? Thank you
The solution I am using is the following:
And to receive the data: