Last active
June 15, 2020 18:39
-
-
Save raulh82vlc/6f68f75e91ee1666ddb1fee094c3805c to your computer and use it in GitHub Desktop.
SearchTweetUseCase Flow collection
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
private val scope = CoroutineScope(taskThreading.uiDispatcher() + SupervisorJob()) | |
@ExperimentalCoroutinesApi | |
override fun execute(query: String, callbackInput: SearchCallback?) { | |
callback = callbackInput | |
callback?.onShowLoader() | |
scope.launch { | |
repository.searchTweet(query) | |
.catch { error -> | |
// error handling | |
onError(error) | |
}.collect { tweets -> | |
// UI actions for each stream | |
onSuccess(tweets) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment