Created
January 26, 2021 23:06
-
-
Save fergusonm/29a27494714dd65c1588a593b88a9dcf to your computer and use it in GitHub Desktop.
rxjava 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() | |
disposable = viewModel.eventsFlow | |
.asObservable() // converting to Rx for the example | |
.subscribe { | |
when (it) { | |
MainViewModel.Event.NavigateToSettings -> {} | |
is MainViewModel.Event.ShowSnackBar -> {} | |
is MainViewModel.Event.ShowToast -> {} | |
} | |
} | |
} | |
override fun onStop() { | |
super.onStop() | |
disposable?.dispose() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment