Last active
December 28, 2022 04:17
-
-
Save manuelvicnt/61880caaf3c7ef5480ba530b29855be5 to your computer and use it in GitHub Desktop.
LocationFlow shareIn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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