This repository contains simple COVID19 data monitoring with android stack MVVM, Live Data, Koin, RxJava, RxBinding, Offline first with simple caching, etc
Multiple API call error handling is a little bit tricky because when one of API call failed the other got cancelled because RxJava ended the stream if the Observable enter onError function.
e.g. when daily endpoint failed but overview endpoint succeed we should show Overview result and do nothing with daily updates. User can reload if he/she wishes to see daily updates.
In order to keep the RxJava stream alive we need to wrap Response with Result class and use onErrorResumeNext function to handle the API throwable.
This PR improves Repository
Multiple API call error handling is a little bit tricky because when one of API call failed the other got cancelled because RxJava ended the stream if the Observable enter onError function.
e.g. when
daily endpoint
failed butoverview endpoint
succeed we should show Overview result and do nothing with daily updates. User can reload if he/she wishes to see daily updates.In order to keep the RxJava stream alive we need to wrap Response with Result class and use onErrorResumeNext function to handle the API throwable.
ref: https://rongi.github.io/kotlin-blog/rxjava/rx/2017/08/01/error-handling-in-rxjava.html
Other improvements :
Preview Loading State:
Preview Connection Error State:
Preview Connection Error State (Only occurs when does not have cached data):