Skip to content

Instantly share code, notes, and snippets.

@Zhuinden
Last active November 27, 2019 21:15
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 Zhuinden/ab154d82ee292009974860766ca92f6e to your computer and use it in GitHub Desktop.
Save Zhuinden/ab154d82ee292009974860766ca92f6e to your computer and use it in GitHub Desktop.
Anemic Repository 2
class MyFragment: Fragment() {
private val compositeDisposable = CompositeDisposable()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
compositeDisposable += myView.events.subscribeBy { event ->
when(event) {
OnButtonPressed -> { ... }
OnTextChanged -> { text -> ... }
OnCheckBoxTicked -> { ... }
}.safe()
}
}
override fun onDestroyView() {
super.onDestroyView()
compositeDisposable.clear()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment