'In Android RxJava, How to call same Single from two classes with and without observing
In my Android app, I have a function that calls multiple APIs and creates a Single Response
fun callApis(): Single<Response>{
...
}
I want to reuse this function from two different classes. In one, I need to handle success and error. In the second class, I don't want to handle any response as there are multiple parallel API calls. How to achieve this?
What I currently do is From LoginViewModel.java
callApis().subscribe();
and from SettingsViewModel.java
callAppis().subscribe(
res -> handleSuccess();
throwable -> handleError();
);
But when any exception comes in callApis(), the LoginViewModel.java subscription will produce a OnErrorNotImplementedException. Is there any way to avoid this error?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
