JavaFX is a Framework for UIs. Nevertheless I would like to use JavaFX ObservableValue for non-UIs (or at least the way). Is this a good idea?! Personally I don't think so (UI-Thread, no concurrency).
In my projects it's pretty common to observe the properties of non-UI-related objects (backend). My current solution is to use an EventBus approach. It's work but when it comes to the UI it feel like a hack to do the databinding.
Example:
private void init () {
myObject.subscribe(this);
textfield.textProperty().addChangeListener( (o,l,n) -> {
myObject.setText(n);
});
}
@Handler
private void handleChangeEvent(final ChangeEvent event) {
Platform.runLater(() -> this.textfield.setText(event.getValue()));
}
This Example becomes quite complex when the object is retrieved by the selected item of a ListView.
What I want:
private void init () {
myObject.textProperty().bindBidirectional(textfield.textProperty());
}