Created
January 26, 2021 23:07
-
-
Save fergusonm/35a9b2ac4ba885ffc659db492f1f83c2 to your computer and use it in GitHub Desktop.
flow observation between start and stop
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 onStart() { | |
super.onStart() | |
job = viewModel.eventsFlow | |
.onEach { | |
when (it) { | |
MainViewModel.Event.NavigateToSettings -> {} | |
is MainViewModel.Event.ShowSnackBar -> {} | |
is MainViewModel.Event.ShowToast -> {} | |
} | |
} | |
.launchIn(viewLifecycleOwner.lifecycleScope) | |
} | |
override fun onStop() { | |
super.onStop() | |
job?.cancel() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment