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/657751eb4440ba81649856afdbf99bf9 to your computer and use it in GitHub Desktop.
Save esilverberg/657751eb4440ba81649856afdbf99bf9 to your computer and use it in GitHub Desktop.
// 🍎
// In our viewDidLoad
viewModel.state.producer.take(duringLifetimeOf: self).startWithValues { [weak self] (state) in
guard let self = self else { return }
switch state {
case .initial: //...
case .error: //...
case .loading: //...
case .started: //...
case .finished: //...
}
}
// 🤖
// In our onCreate
matchViewModel.matchState.observe(this, Observer { matchState ->
when(matchState) {
is MatchState.Initialized -> //...
is MatchState.Error -> //...
is MatchState.Loading -> //...
is MatchState.Started -> //...
is MatchState.Finished -> //...
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment