This question gave me a general idea but I'm still struggling.
My fragment -
// Reset email sent observer
viewModel.isEmailSent.observe(viewLifecycleOwner, { flag ->
onResetMailSent(flag)
})
My ViewModel -
val isMailSent: MutableLiveData<Boolean> = MutableLiveData(false)
isEmailSent = liveData {
emit(firebaseAuthRepo.sendPasswordResetMail(emailId))
}
My Repository -
suspend fun sendPasswordResetMail(emailId: String): Boolean {
firebaseAuth?.sendPasswordResetEmail(emailId)
?.addOnCompleteListener {
if (it.isSuccessful) { }
}
?.addOnFailureListener {
}
}
question -
How do I inform the viewmodel that the repo's 'addOnCompleteListener' or 'addOnFailureListener' has been called? I was thinking of returning a boolean flag but seems like I can't place a 'return' statement inside the listeners.
IDE says that the 'suspend' modifier is redundant. Why is that?