A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-play-services/index.html below:

Website Navigation


coroutines-play-services | kotlinx.coroutines – Kotlin Programming Language

Integration with Google Play Services Tasks API.

Extension functions:

Example

Using Firebase APIs becomes simple:

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

If the Task supports cancellation via passing a CancellationToken, pass the corresponding CancellationTokenSource to asDeferred or await to support bi-directional cancellation:

val cancellationTokenSource = CancellationTokenSource()
val currentLocationTask = fusedLocationProviderClient.getCurrentLocation(PRIORITY_HIGH_ACCURACY, cancellationTokenSource.token)
val currentLocation = currentLocationTask.await(cancellationTokenSource) // cancelling `await` also cancels `currentLocationTask`, and vice versa

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4