- Notifications
You must be signed in to change notification settings - Fork28
Demo that shows how to use RxJava with Android Data Binding ObservableFields
License
TangoAgency/android-data-binding-rxjava
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Simple demo developed with love atTango which demonstrates how to wrap Android DataBinding ObservableField into RxJava's Observable.
With this solution it is possible to register for ObservableField's value changes and use it with RxJava operators.
You can read Medium story which explains this concept -RxJava meets Android Data Binding.
publicstaticclassMainViewModel {publicObservableField<String>firstName =newObservableField<>();publicObservableField<String>lastName =newObservableField<>();publicObservableField<String>helloText =newObservableField<>();publicObservableBooleanhelloButtonEnabled =newObservableBoolean(false);publicMainViewModel() {Observable.combineLatest(toObservable(firstName),toObservable(lastName), (firstName,lastName) ->StringUtils.isNotNullOrEmpty(firstName) &&StringUtils.isNotNullOrEmpty(lastName)) .subscribe(result -> {helloButtonEnabled.set(result);if (!result) {helloText.set(StringUtils.EMPTY); } },Throwable::printStackTrace); }publicvoidbuttonClicked() {helloText.set(String.format("Hello %s %s !",firstName.get(),lastName.get())); }}
You can findtoObservable method implementation inRxUtils.java class.
It uses ObservableField'sOnPropertyChangedCallback and expose property change events to the "RxWorld".
About
Demo that shows how to use RxJava with Android Data Binding ObservableFields
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Contributors2
Uh oh!
There was an error while loading.Please reload this page.
