networkObserver get Exception so the final result is onError in your example when network fail even if localObeserver has data
shakil807g opened this issue · comments
networkObserver().publish(
network ->//
Observable.merge(network,//
localObserver().takeUntil(network)));
interesting.are you pointing to the same issue as this -> https://www.reddit.com/r/androiddev/comments/5d8gn8/learning_rx_by_example/da385oz/ ?
if yes, then i could potentially change the code to handle via onErrorResumeNext
etc. but i also am interested in keeping the example to a bare minimum vs. a comprehensive one which handles multiple edge cases.
hmm.. but not sure if this is important enough to be a legit case vs an edge case
hmm..right but it would be helpful if you provide an example using onErrorResumeNext for that edge case because in my case i am getting Exception very often get from networkObserver()
the code snippet would look something like this:
private Observable<Contributor> getFreshNetworkData() {
String githubToken = getResources().getString(R.string.github_oauth_token);
GithubApi githubService = GithubService.createGithubService(githubToken);
return githubService
.contributors("square", "retrofit")
.onErrorReturn(throwable -> {
Timber.e(throwable, "Error encountered getting fresh network data");
return Collections.emptyList();
})
.flatMap(Observable::fromIterable)
.doOnSubscribe((data) -> new Handler(Looper.getMainLooper()).post(() -> adapterSubscriptionInfo.add(
"(network) subscribed")))
.doOnComplete(() -> new Handler(Looper.getMainLooper()).post(() -> adapterSubscriptionInfo.add(
"(network) completed")));
}
leaving the code snippet here for folks who are interested in knowing how to address this.
still want to keep the example clean, cause adding it to the actualy example makes it look like a mini app, which can deter the learning.
closing this for now with above snippet. feel free to reopen if you feel something else needs to be done.