Last active
December 22, 2021 15:56
-
-
Save fergusonm/8d202e5e8ba57d85fe4c77c708600e91 to your computer and use it in GitHub Desktop.
View observing view state updates
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
// 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