Created
January 9, 2023 15:37
-
-
Save aqua30/994c4c12763c6d1c801709e2cc08c6a1 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 MainViewModel: ViewModel() { | |
private val _creditScore = MutableStateFlow(0) | |
private val _age = MutableStateFlow(18) | |
val isEligible = combine(_creditScore, _age) { creditScore, age -> | |
creditScore > 400 && age > 18 && age < 70 | |
} | |
fun creditScore(score: Int) { | |
_creditScore.update { | |
score | |
} | |
} | |
fun age(age: Int) { | |
_age.update { | |
age | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment