Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Created May 21, 2021 15:19
Show Gist options
  • Save manuelvicnt/a26e26179b80d8a278c634cc5f7a9a78 to your computer and use it in GitHub Desktop.
Save manuelvicnt/a26e26179b80d8a278c634cc5f7a9a78 to your computer and use it in GitHub Desktop.
class LocationFragment: Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
// ...
viewLifecycleOwner.lifecycleScope.launch {
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
locationProvider.locationFlow().collect {
// New location! Update the map
}
}
}
}
}
@belinwu
Copy link

belinwu commented Jan 3, 2023

Should I use repeatOnLifecycle with Lifecycle.State.CREATED in Fragment for collecting UI State provided by ViewModel?

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