Skip to content

Instantly share code, notes, and snippets.

@raulh82vlc
Created June 9, 2020 22:08
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 raulh82vlc/01abea21eeb72d6fd0b37bc6f890707f to your computer and use it in GitHub Desktop.
Save raulh82vlc/01abea21eeb72d6fd0b37bc6f890707f to your computer and use it in GitHub Desktop.
search returning a single from a suspend function
override fun search(token: String, query: String)
: Single<Either<Throwable, List<TweetApiModel>>>
= rxSingle {
val response = twitterApi.search(requestsIOHandler.getTokenFormatted(token), query)
if (requestsIOHandler.searchIsSuccessful(response)) {
val tweets = requestsIOHandler.getTweets(response)
Either.right(tweets)
} else {
Either.left(EmptyResponseException())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment