You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Handle gracefully connectivity errors, especially when no data available offline.
Define a ComicError sealed class with 2 branches NetworkError and EmptyError
the idea is that QueryViewModel.results property now will be an LiveData<Either<ComicError,T>> instead of LiveData<T>, create a new ViewState QueryViewState.Error that contains a ComicError now on UI implementation handle it accordingly, for suggestions, for example, could be
@BindingAdapter("suggestions")
funbindSuggestions(search:FloatingSearchView, liveData:List<Either<ComicError,String>?) = liveData?.let {
when (it) {
isLeft->QuerySearchSuggestion(it.a.toHumanError())
isRigth-> it.b.map { QuerySearchSuggestion(it) }
}.let { search.swapSuggestions(it) }
}
fun ComicError.toHumanError(): String=when(this) {
isNetworkError->"no internet conection"isEmptyError->"search without results"
}
the search feature will be a more "harder" as the UI change, when a ComicError happens, the list could be hidden and display an icon with text that change based on it, as properties could be observed by more than one observer, actual @BindingAdapter will update adapter on Right values and hide the list on Left one, and create a new one to the error view that update the text/icon on Left values and hide it on Right
The text was updated successfully, but these errors were encountered:
Handle gracefully connectivity errors, especially when no data available offline.
Define a
ComicError
sealed class with 2 branchesNetworkError
andEmptyError
the idea is that
QueryViewModel.results
property now will be anLiveData<Either<ComicError,T>>
instead ofLiveData<T>
, create a new ViewStateQueryViewState.Error
that contains aComicError
now on UI implementation handle it accordingly, for suggestions, for example, could bethe search feature will be a more "harder" as the UI change, when a
ComicError
happens, the list could be hidden and display an icon with text that change based on it, as properties could be observed by more than one observer, actual@BindingAdapter
will update adapter onRight
values and hide the list onLeft
one, and create a new one to the error view that update the text/icon onLeft
values and hide it onRight
The text was updated successfully, but these errors were encountered: