Is there a correct way to await safely? I'm inter...
# coroutines
c
Is there a correct way to await safely? I'm interacting with Firebase Auth methods that return
Task<Void>
and would like a way to synchronously execute them while catching certain exceptions they might throw. I'm having trouble finding the right terms to lookup some of the behaviour, so I'd appreciate anyone setting me in the right direction!
m
If you add this dependency:
Copy code
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.4.1'
Then you can call await on Tasks like this:
Copy code
try {
   task.await()
} catch (e: Exception) {
}
More info here: https://developers.google.com/android/guides/tasks#kotlin_coroutine
❤️ 1
c
excellent - thank you for the example!