Skip to content

Instantly share code, notes, and snippets.

@Zhuinden
Last active November 27, 2019 21:13
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/7cf9eb2839adf8152d6cc081881fcdf5 to your computer and use it in GitHub Desktop.
Save Zhuinden/7cf9eb2839adf8152d6cc081881fcdf5 to your computer and use it in GitHub Desktop.
Anemic Repository 4
class MyView(...): ... {
sealed class Events {
class OnTextChanged(val text: String): Events()
class OnButtonPressed(): Events()
class OnCheckBoxTicked(): Events()
}
lateinit var events: Observable<Events>
private set
override fun onFinishInflate() {
super.onFinishInflate()
events = Observable.merge(
button.clicks().map {
OnButtonPressed()
},
editText.textChanges().map { text ->
OnTextChanged(text)
},
checkBox.checkChanges().map { checked ->
OnCheckBoxTicked()
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment