2

So right now I'm reading about RxJavaFX and stumbled upon the following example:

var comboBox = new ComboBox <String> ();
comboBox.getItems().setAll("Alpha", "Beta", "Gamma", "Delta", "Epsilon");
JavaFxObservable.valuesOf(comboBox.valueProperty())
    .subscribe(v - > System.out.println(v + " was selected "));

Why would I use the example above instead of this?

var comboBox = new ComboBox <String> ();
comboBox.getItems().setAll("Alpha", "Beta", "Gamma", "Delta", "Epsilon");
comboBox.setOnAction(ae -> System.out.println(comboBox.getValue()));

I can't see the benefit of using RxJavaFX here. What am I missing?

M. Malkon
  • 145
  • 1
  • 6
  • 2
    In the simple example you provided? No benefit. But [RxJavaFX](https://github.com/ReactiveX/RxJavaFX), which is a JavaFX "bridge" to the greater [RxJava](https://github.com/ReactiveX/RxJava) library, allows you to create large chains of operations; this includes transformations, thread communication, etc. – Slaw Mar 16 '19 at 09:44
  • See also [*Differences from ReactFX*](https://github.com/ReactiveX/RxJavaFX#differences-from-reactfx) regarding _asynchronous_ design. – trashgod Mar 16 '19 at 13:34

0 Answers0