Skip to content

Instantly share code, notes, and snippets.

@fergusonm
Last active December 22, 2021 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fergusonm/8d202e5e8ba57d85fe4c77c708600e91 to your computer and use it in GitHub Desktop.
Save fergusonm/8d202e5e8ba57d85fe4c77c708600e91 to your computer and use it in GitHub Desktop.
View observing view state updates
// In your view/fragment
viewLifecycleOwner.lifecycleScope.launch {
viewModel.viewState
.flowWithLifecycle(viewLifecycleOwner.lifecycle, Lifecycle.State.STARTED)
.collect {
// do something with the UI updates
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment