This is my current Login. I have to check if the user type is User or Restaurant. Its kind of slow because of “observeAsState”. Could someone show me a better and efficient solution please?
loginViewModel.loginStatus.observeAsState(loginViewModel.loginStatus).apply {
if (this.value == true) {
loginViewModel.userInfo.observeAsState(null).apply {
if (this.value!=null) {
val isUser = loginViewModel.userInfo.value?.isUser
showProgress = false
if (isUser == true) {
println("USERRRRR")
NavigateToUsers()
} else {
println("RESTAURAMT")
NavigateToRestaurants()
}
}
}
}
if(this.value == false)
{
Toast.makeText(context, "Can't join. Wrong password!", Toast.LENGTH_LONG).show()
}
}