RFR: JDK-8304439: Subscription based listeners [v7]

Michael Strauß mstrauss at openjdk.org
Sun Jul 9 19:37:07 UTC 2023


On Sun, 9 Jul 2023 18:07:33 GMT, Jose Pereda <jpereda at openjdk.org> wrote:

>> John Hendrikx has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Add newline at end of ConditionalBinding file
>
> modules/javafx.base/src/main/java/javafx/beans/value/ObservableValue.java line 345:
> 
>> 343:         ChangeListener<T> listener = (obs, old, current) -> subscriber.accept(current);
>> 344: 
>> 345:         subscriber.accept(getValue());  // eagerly send current value
> 
> What is the reason of this logic being done only for the Consumer and not for the BiConsumer (or the Runnable for that matter)?

There doesn't seem to be a way to do the same for the other overloads:
* The `Runnable` overload is specified to be invoked _when the value becomes invalid_, which isn't happening when a subscription is added. Eagerly invoking the runnable without a valid->invalid transition does not conform to the specification of an invalidation listener.
* The `BiConsumer` overload accepts two values: the old value and the new value. But we don't know the old value, we only know the current value. Using the current value as both old and new value does not conform to the specification of a change listener.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1069#discussion_r1257531578


More information about the openjfx-dev mailing list