Created
July 2, 2018 22:42
-
-
Save featzima/deac6def7045093f9fdeb57d1db1d698 to your computer and use it in GitHub Desktop.
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
data class MyViewModel( | |
private val myEndpoint: MyEndpoint): DisposableViewModel() { | |
private val searchText = ChannelLiveData("") | |
private val inProgress = ChannelLiveData(false) | |
private val result = ChannelLiveData("") | |
init { | |
disposableLaunch { | |
searchText.consumeEach { searchText -> | |
inProgress.send(true) | |
val searchResult = myEndpoint.search(searchText) | |
inProgress.send(false) | |
result.send(searchResult) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment