Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Last active December 28, 2022 04:17
Show Gist options
  • Save manuelvicnt/61880caaf3c7ef5480ba530b29855be5 to your computer and use it in GitHub Desktop.
Save manuelvicnt/61880caaf3c7ef5480ba530b29855be5 to your computer and use it in GitHub Desktop.
LocationFlow shareIn
val FusedLocationProviderClient.locationFlow() = callbackFlow<Location> {
...
}.shareIn(
// Make the flow follow the applicationScope
applicationScope,
// Emit the last emitted element to new collectors
replay = 1,
// Keep the producer active while there are active subscribers
started = SharingStarted.WhileSubscribed()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment