试图了解RxJavaFX

时间:2019-03-15 23:29:40

标签: java javafx rx-javafx

所以现在我正在阅读有关RxJavaFX的内容,偶然发现了以下示例:

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 "));

为什么我要使用上面的示例代替它?

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

我在这里看不到使用RxJavaFX的好处。我想念什么?

0 个答案:

没有答案