Last active
September 3, 2018 20:12
-
-
Save paulocns/cd3cec4bb3b9e14326d1f6ce0f090915 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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