RxJavaFX icon indicating copy to clipboard operation
RxJavaFX copied to clipboard

Change object not emitted when observed property had changed to null

Open pkrysztofiak opened this issue 6 years ago • 0 comments

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.

pkrysztofiak avatar Mar 26 '19 09:03 pkrysztofiak