Created
September 19, 2021 17:10
-
-
Save fabioCollini/edc93f6b89d75981f4cd47262d14c590 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 CalculatorViewModel : ViewModel() { | |
var v1 = MutableStateFlow("0") | |
var v2 = MutableStateFlow("0") | |
val result = v1.combine(v2) { a, b -> a to b}.mapLatest { | |
sum(it.first, it.second) | |
}.stateIn(viewModelScope, SharingStarted.Lazily, "0") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment