Skip to content

Instantly share code, notes, and snippets.

@aqua30
Created January 9, 2023 15:37
Show Gist options
  • Save aqua30/994c4c12763c6d1c801709e2cc08c6a1 to your computer and use it in GitHub Desktop.
Save aqua30/994c4c12763c6d1c801709e2cc08c6a1 to your computer and use it in GitHub Desktop.
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