Last active
September 9, 2021 17:04
-
-
Save ericntd/8109ccdf4054b9ea332fccf5bafb87b1 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
class SomeViewModel(val inputStream: Observable<SomeDataType>, ...) { | |
private val viewState = MutableLiveData<ViewState>() | |
init { | |
doStep1() | |
//... | |
.doStepK() | |
.zipWith(inputStream) // combine/ merge 2 streams into 1 using Pair | |
.map { pair -> | |
val stepKresult = pair.first | |
val input = pair.second // data from button click | |
someUsefulVariable = ... // derived from stepKresult and button click data | |
return@map processData(stepKResult, someUsefulVariable) | |
} | |
.handleResult { finalResult -> viewState.value = ViewState.DataLoaded(...) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment