Created
April 9, 2018 21:45
-
-
Save dariopellegrini/6a82945f4cecf04b7b3579ac47075a5c to your computer and use it in GitHub Desktop.
Android EditText data binding with RxKotlin
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
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