Skip to content

Instantly share code, notes, and snippets.

@thomaskioko
Created July 25, 2023 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomaskioko/23a18e2d62f61fcb43af9c2f437b25f5 to your computer and use it in GitHub Desktop.
Save thomaskioko/23a18e2d62f61fcb43af9c2f437b25f5 to your computer and use it in GitHub Desktop.
{
...
fetcher = Fetcher.of {
val apiResponse = remoteDataSource.getPopularShows(page = 1)
when (apiResponse) {
is ApiResponse.Success -> {
// Map and cache data to local-source.
}
is ApiResponse.Error.HttpError -> throw Throwable("${response.errorMessage}")
is ApiResponse.Error.GenericError -> throw Throwable("${response.errorMessage}")
is ApiResponse.Error.SerializationError -> throw Throwable("${response.errorMessage}")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment