Skip to content

Instantly share code, notes, and snippets.

@paulocns
Last active September 3, 2018 20:12
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/cd3cec4bb3b9e14326d1f6ce0f090915 to your computer and use it in GitHub Desktop.
Save paulocns/cd3cec4bb3b9e14326d1f6ce0f090915 to your computer and use it in GitHub Desktop.
class SearchShows @Inject
constructor(private val showRepository: ShowRepository) : UseCase() {
var query: String? = null
override fun buildUseCaseObservable(): Single<List<ShowResponse>> {
return showRepository.searchShow(query).flatMapPublisher { Flowable.fromIterable(it) }
.flatMapSingle({ showInfo:ShowInfo ->
showRepository.showRating(showInfo.show.ids.trakt)
.subscribeOn(Schedulers.io())
.map { rating ->
ShowResponse(showInfo.show.title, rating
.rating)
}
},false, 4).toList()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment