Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Last active August 12, 2022 11:35
Show Gist options
  • Select an option

  • Save manuelvicnt/6629b53e33b97c127508227ed6e0bee4 to your computer and use it in GitHub Desktop.

Select an option

Save manuelvicnt/6629b53e33b97c127508227ed6e0bee4 to your computer and use it in GitHub Desktop.
@Composable
fun LocationUI(locationFlow: Flow<Location>) {
val location by locationFlow.collectAsStateWithLifecycle()
// Current location, do something with it
}
@OriolFernandez
Copy link

flowWithLifecycle returns a Flow right? then locationFlowLifecycleAware is a Flow , but a flow does not have an initial value as StateFlow has, so I'd say val location by locationFlowLifecycleAware.collectAsState() is incorrect since needs an initial value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment