Skip to content

Instantly share code, notes, and snippets.

@KunalChaubal
Last active June 8, 2020 10:42
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 KunalChaubal/4811ba6a06475643a0614c990c766de7 to your computer and use it in GitHub Desktop.
Save KunalChaubal/4811ba6a06475643a0614c990c766de7 to your computer and use it in GitHub Desktop.
fun fetchDogBreedList(): LiveData<List<String>> {
val dogBreedLiveData = fetchDetailsRepo.fetchBreedList()
return Transformations.map(dogBreedLiveData) {
when (it.status) {
Resource.Status.SUCCESS -> {
// Returns a list of 'name' string
it.data?.map { it.name }
}
Resource.Status.ERROR -> {
// Handle Error
null
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment