On Wed, 28 Jun 2023 15:02:22 GMT, Kevin Rushforth <k...@openjdk.org> wrote:

>> I prefer `subscribe` with overloads, as this comes closest to the existing 
>> naming scheme of JavaFX listener operations (`addListener` / 
>> `removeListener` with overloads).
>> 
>> I would also like to see a subscription-style API that works with the 
>> existing listener types. This has the advantage of not needing a wrapper for 
>> each listener registration, and it can be a drop-in replacement in many 
>> places where JavaFX listeners are used today.
>> 
>> My suggestion is to have the following new operations:
>> * `subscribe` (`Runnable`, `Consumer`, `BiConsumer`)
>> * `subscribeListener` (`InvalidationListener`, `ChangeListener`)
>> 
>> This pairs nicely with the existing operations:
>> * `addListener` (`InvalidationListener`, `ChangeListener`)
>> * `removeListener` (`InvalidationListener`, `ChangeListener`)
>
>> My suggestion is to have the following new operations:
>> 
>> * `subscribe` (`Runnable`, `Consumer`, `BiConsumer`)
> 
> This seems reasonable. I could be talked into the longer names, but I prefer 
> the overloaded `subscribe` name.
> 
>> * `subscribeListener` (`InvalidationListener`, `ChangeListener`)
> 
> This might be a useful follow-on Enhancement, but I wouldn't do it as part of 
> this one.

I prefer short names here as often there will be a lambda or method reference 
following it that makes it clear what you're doing, so I guess that's a vote 
for `subscribe` plus overrides then.

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

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

Reply via email to