Skip to content

Instantly share code, notes, and snippets.

@dariopellegrini
Created April 9, 2018 21:45
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 dariopellegrini/6a82945f4cecf04b7b3579ac47075a5c to your computer and use it in GitHub Desktop.
Save dariopellegrini/6a82945f4cecf04b7b3579ac47075a5c to your computer and use it in GitHub Desktop.
Android EditText data binding with RxKotlin
infix fun Variable<String>.binding(editText: EditText) {
var block = false
this.observable.subscribe {
if (block == false) {
block = true
editText.setText(it)
block = false
}
}
editText.rx.subscribe {
if (block == false) {
block = true
this.value = it
block = false
}
}
}
infix fun EditText.binding(variable: Variable<String>) {
variable binding this
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment