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

Michael Strauß mstrauss at openjdk.org
Sun Jul 9 20:14:04 UTC 2023


On Sun, 2 Jul 2023 11:46:19 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

>> Makes `Subscription` public (removing some of its methods that are unnecessary), and adds methods that can provide `Subscription`s in `ObservableValue`.
>
> 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/Observable.java line 99:

> 97:     /**
> 98:      * Creates a {@link Subscription} on this value which calls the given
> 99:      * {@code runnable} whenever it becomes invalid.

I think the documentation for these new methods should go into more detail and clearly explain the semantics. These are fundamental concepts, and I think it's a good idea to err on the side of over-explaining. Here's a suggestion:


Creates a {@code Subscription} for invalidation events of this {@code Observable}.
<p>
The specified {@code runnable} will be invoked when the {@code Observable} transitions to the
<em>invalid</em> state. This happens when the observed value is changed, usually by calling
the {@link ObservableValue#setValue} method. Note that the specified {@code runnable} will not
be invoked for subsequent value changes unless the {@code Observable} has transitioned to the
<em>valid</em> state again, usually by invoking the {@link ObservableValue#getValue} method.
<p>
An {@code Observable} is automatically validated on every change when a {@link ChangeListener}
or a {@link Consumer} or {@link BiConsumer} subscription is added.

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

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


More information about the openjfx-dev mailing list