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

John Hendrikx jhendrikx at openjdk.org
Tue Apr 18 00:07:54 UTC 2023


On Mon, 17 Apr 2023 23:48:54 GMT, Nir Lisker <nlisker at openjdk.org> wrote:

> Just took a quick look.
> 
> Ideally, we would not split the world into subscriptions and listeners. Adding a return type to `addListener` and `removeListener` is source compatible, but not binary. Is this something that we strictly can't do? Is the disruption factor too high?

I think it would be quite problematic; you couldn't incorporate frameworks into JavaFX anymore then that are not yet updated, or are no longer maintained.  Reactfx would be a good example of the latter.

There is still some use for the standard listener methods; there are some rare cases where having the `Observable` or `ObservableValue` parameter is actually useful. I'd prefer to drop this parameter from the subscription variants though as it is rarely useful and makes the lambda's / method refs awkward to use.  For methods refs your method must have an unused `Observable` or `ObservableValue` parameter (and sometimes these methods are not under your control, like `ObservableValue::setValue`, or `SelectionModel::select`)

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

PR Comment: https://git.openjdk.org/jfx/pull/1069#issuecomment-1512257656


More information about the openjfx-dev mailing list