• Home
Name Date Size #Lines LOC

..--

api/03-May-2024-75

src/03-May-2024-10877

test/03-May-2024-173140

README.mdD03-May-20241,008 3021

build.gradleD03-May-20241.2 KiB4637

package.listD03-May-202428 11

README.md

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