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

Nir Lisker nlisker at openjdk.org
Thu Jul 13 02:29:23 UTC 2023


On Tue, 11 Jul 2023 23:19:21 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:
> 
>   Fix subscriber -> valueSubscriber

modules/javafx.base/src/main/java/javafx/beans/value/ObservableValue.java line 307:

> 305:     /**
> 306:      * Creates a {@link Subscription} on this {@code Observable} which calls the given
> 307:      * {@code changeSubscriber} with the old and new value whenever its value changes.

* There's no need to link `Subscription` since it's linked in the method description.
* Maybe say "on this `{@code ObservableValue}`" to be more specific, even though it's also an `Observable`.
* I would also note the similarities to a `ChangeListener` since it's used internally.

Maybe this?

Creates a {@code Subscription} on this {@code ObservableValue} that calls the given {@code 
changeSubscriber} with the old and new values whenever its value changes. This {@code Subscription}
is akin to a {@code ChangeListener} without the {@code ObservableValue} parameter.

modules/javafx.base/src/main/java/javafx/beans/value/ObservableValue.java line 310:

> 308:      * <p>
> 309:      * The parameters supplied to the {@link BiConsumer} are the old and new value
> 310:      * respectively.

"values, respectively"

modules/javafx.base/src/main/java/javafx/beans/value/ObservableValue.java line 356:

> 354:      * {@code ObservableValue} when some condition holds.
> 355:      *
> 356:      * @param valueSubscriber a {@link Consumer} to supply with the values of this

No need for a link to `Consumer`.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1069#discussion_r1261833227
PR Review Comment: https://git.openjdk.org/jfx/pull/1069#discussion_r1261827415
PR Review Comment: https://git.openjdk.org/jfx/pull/1069#discussion_r1261829173


More information about the openjfx-dev mailing list