Skip to content

Instantly share code, notes, and snippets.

@paulocns
Last active September 3, 2018 20:29
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/2a6af363299c0a07b72434d99759b523 to your computer and use it in GitHub Desktop.
Save paulocns/2a6af363299c0a07b72434d99759b523 to your computer and use it in GitHub Desktop.
class SearchShows @Inject
constructor(private val showRepository: ShowRepository, private val resourceRepository: ResourceRepository) : UseCase() {
private var query: String? = null
fun setQuery(query: String) {
this.query = query
}
override fun buildUseCaseObservable(): Single<String> {
return showRepository.searchShow(query).map { showInfos ->
if (!showInfos.isEmpty() && showInfos[0].show != null) {
showInfos[0].show.title
} else {
resourceRepository.notFoundShow
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment