Created
June 9, 2020 22:08
-
-
Save raulh82vlc/01abea21eeb72d6fd0b37bc6f890707f to your computer and use it in GitHub Desktop.
search returning a single from a suspend function
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
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