I know it's a more general question than usual, but It would be amazing if I will start to understand how I implement this crucial part.
I have simple retrofit call that I handle with RxJava:
public interface MoviesApi {
@GET("3/movie/popular")
Single<Movies> getAllMovies(
@Query("api_key") String apiKey
);
}
And in my repository I am handling the response:
ApiService.getMoivesApi().getMovies(API_KEY)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<AllMovies>() {
@Override
public void onSuccess(Movies Movies) {
movies.setValue(movies);
}
@Override
public void onError(Throwable e) {
e.printStackTrace();
}
})
How can I handle all the possible cases?
For example: network error/loading/empty response/wrong api etc..
I read about abstract class that handle this cases, but I have hard time to understand how to create this such a class