Proyectos
Ver en GitHub
TangoAgency/android-data-binding-rxjava
Acerca de
Demostración de cómo usar RxJava con ObservableFields de Android Data Binding.
Desarrollo web y de aplicacionesCrecimiento de estrellas medido
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
README.md
Originalandroid-data-binding-rxjava
Simple demo developed with love at Tango 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.
Example code
public static class MainViewModel {
public ObservableField<String> firstName = new ObservableField<>();
public ObservableField<String> lastName = new ObservableField<>();
public ObservableField<String> helloText = new ObservableField<>();
public ObservableBoolean helloButtonEnabled = new ObservableBoolean(false);
public MainViewModel() {
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);
}
public void buttonClicked() {
helloText.set(String.format("Hello %s %s !", firstName.get(), lastName.get()));
}
}

How it works
You can find toObservable method implementation in RxUtils.java class.
It uses ObservableField's OnPropertyChangedCallback and expose property change events to the "RxWorld".
Explorar proyectos relacionados
Cargando…