ReactiveX / RxJavaFX

RxJava bindings for JavaFX
Apache License 2.0
519 stars 67 forks source link

Change object not emitted when observed property had changed to null #86

Open pkrysztofiak opened 5 years ago

pkrysztofiak commented 5 years ago
import io.reactivex.rxjavafx.observables.JavaFxObservable;
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.stage.Stage;

public class ChangesOfNullApp extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {
        StringProperty stringProperty = new SimpleStringProperty("firstValue");

        JavaFxObservable.changesOf(stringProperty)
        .subscribe(change -> System.out.println("oldValue=" + change.getOldVal() + ", newValue=" + change.getNewVal()));

        stringProperty.set(null);
        stringProperty.set("secondValue");
        stringProperty.set("thirdValue");
    }
}

The output is: oldValue=null, newValue=secondValue oldValue=secondValue, newValue=thirdValue Imo there is first missing emission which should be logged as: oldValue=firstValue, newValue=null Generally there are no change emissions when property was set to null.