Last active
March 15, 2021 19:18
-
-
Save fergusonm/32b5be1af5bf6dd1f7f286c2f1081eda to your computer and use it in GitHub Desktop.
lanchWhenX flow collector
This file contains hidden or 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
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
// get your view model here | |
lifecycleScope.launchWhenStarted { | |
viewModel.eventsFlow | |
.collect { | |
when (it) { | |
MainViewModel.Event.NavigateToSettings -> {} | |
is MainViewModel.Event.ShowSnackBar -> {} | |
is MainViewModel.Event.ShowToast -> {} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment