Skip to content

Instantly share code, notes, and snippets.

@esilverberg
Last active November 25, 2020 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esilverberg/6baabfde2513376927c14080ec146277 to your computer and use it in GitHub Desktop.
Save esilverberg/6baabfde2513376927c14080ec146277 to your computer and use it in GitHub Desktop.
// 🍎
// in viewDidLoad
viewModel.events.take(duringLifetimeOf: self).observeValues { [weak self] (event) in
guard let self = self else { return }
switch event {
case .mutualMatch: //...
case .premiumRequired: //...
case .exitMatch: //...
}
}
// 🤖
// in onResume
disposables += matchViewModel.events.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
// onNext:
{ handleEvent(it) },
// onError:
{ LOGE(TAG, "Error observing events") })
private fun handleEvent(event: MatchEvent) {
when (event) {
is MatchEvent.MutualMatch -> //...
is MatchEvent.PremiumRequired -> //...
is MatchEvent.ExitMatch -> //..
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment