我想在 firebase 中使用协程来实现登录功能
private suspend fun signin() {
var email = binding.emailArea.text.toString()
var password = binding.passwordArea.text.toString()
return withContext(Dispatchers.IO) {
auth.signInWithEmailAndPassword(email,password).await()
}
}
Run Code Online (Sandbox Code Playgroud)
但我不知道签名函数真正返回什么。
CoroutineScope(Dispatchers.IO).launch {
val result = async { signin() }
//how to utilize result?
}
Run Code Online (Sandbox Code Playgroud)
我知道等待返回被推迟。但我不知道如何使用这个功能。
android kotlin firebase firebase-authentication kotlin-coroutines