1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
# Module kotlinx-coroutines-play-services
Integration with Google Play Services [Tasks API](https://developers.google.com/android/guides/tasks).
Extension functions:
| **Name** | **Description**
| -------- | ---------------
| [Task.await][await] | Awaits for completion of the Task (cancellable)
| [Deferred.asTask][asTask] | Converts a deferred value to a Task
## Example
Using Firebase APIs becomes simple:
```kotlin
FirebaseAuth.getInstance().signInAnonymously().await()
val snapshot = try {
FirebaseFirestore.getInstance().document("users/$id").get().await() // Cancellable await
} catch (e: FirebaseFirestoreException) {
// Handle exception
return@async
}
// Do stuff
```
[await]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-play-services/kotlinx.coroutines.tasks/com.google.android.gms.tasks.-task/await.html
[asTask]: https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-play-services/kotlinx.coroutines.tasks/kotlinx.coroutines.-deferred/as-task.html
|