I am new to rxjava2, and I want to use it to work with my existing code to solve the ignoring Callback hell. The main task is something like the code below :
SomeTask.execute(new Callback() {
@Override
public void onSuccess(Data data) {
// I want to add data into observable stream here
}
@Override
public void onFailure(String errorMessage) {
// I want to perform some different operations
// to errorMessage rather than the data in `onSuccess` callback.
// I am not sure if I should split the data stream into two different Observable streams
// and use different Observers to accomplish different logic.
// and I don't know how to do it.
}
}
I have done some digging in Google and Stackoverflow, but still didn't find the perfect solution to create a observable to achieve these two goals.
- Wrap a existing Callback function.
- Process different Callback data in different logic.
Any suggestion would be a great help.
Pair<Data, ErrorMessage>as the type so you can have multiple of the two.