Created
September 7, 2016 12:59
-
-
Save radzio/ae45b91db1956d8ae9f6a82b873c16bf to your computer and use it in GitHub Desktop.
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
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())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment