Skip to content

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

@pkrysztofiak

Description

@pkrysztofiak
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions