Skip to content

Instantly share code, notes, and snippets.

@paulocns
Last active August 16, 2018 02:19
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 paulocns/fbe799caca0540b4d7a90c215403f743 to your computer and use it in GitHub Desktop.
Save paulocns/fbe799caca0540b4d7a90c215403f743 to your computer and use it in GitHub Desktop.
class SearchShows @Inject
constructor(private val showRepository: ShowRepository) :
UseCase<List<ShowResponse>>() {
var query: String? = null
override suspend fun executeOnBackground(): List<ShowResponse> {
query?.let { query ->
return showRepository.searchShow(query).map {
background {
val rating: Rating = showRepository.showRating(it.show!!.ids!!.trakt!!)
ShowResponse(it.show.title!!, rating.rating)
}
}.map {
it.await()
}
}
return arrayListOf()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment