Last active
September 3, 2018 20:29
-
-
Save paulocns/2a6af363299c0a07b72434d99759b523 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, 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