Skip to content

Instantly share code, notes, and snippets.

@fergusonm
Created January 26, 2021 23:06
Show Gist options
  • Save fergusonm/29a27494714dd65c1588a593b88a9dcf to your computer and use it in GitHub Desktop.
Save fergusonm/29a27494714dd65c1588a593b88a9dcf to your computer and use it in GitHub Desktop.
rxjava observation between start and stop
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