Last active
November 27, 2019 21:15
-
-
Save Zhuinden/ab154d82ee292009974860766ca92f6e to your computer and use it in GitHub Desktop.
Anemic Repository 2
This file contains 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
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