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

Andy Goryachev angorya at openjdk.org
Fri Jun 23 22:31:09 UTC 2023


On Fri, 23 Jun 2023 21:58:37 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>>> | invalidation | values | changes |
>>> |---|---|---|
>>> |`subscribe(Runnable)`(*)|`subscribe(Consumer)`(*)|`subscribe(BiConsumer)`(*)|
>>> |`subscribeInvalidations(Runnable)`|`subscribeValues(Consumer)`|`subscribeChanges(BiConsumer)`|
>>> |`invalidationsTo(Runnable)`|`valuesTo(Consumer)`|`changesTo(BiConsumer)`|
>>> 
>>> (*) May limit future listener types that have same arity, but can still be a good choice
>> 
>> My preference is in the order you listed them. If we go with `subscribe`, using method name overloading, do want to add a future overload that takes a type with the same arity as one of the existing three, we can always assign a new name to that new method (since adding another overload wouldn't be source compatible, we would likely need a new name at that point).
>> 
>> @nlisker @andy-goryachev-oracle @mstr2 - what do you think?
>
>> On that same topic of naming methods:
>> 
>> What do people think of `Subscription#unsubscribe`? Should it be `cancel`? Something else? Okay as it is?
> 
> OK as is. Especially if we go with one of the two choices with "subscribe" in the name.

I might prefer the second option, subscribeXXX().
And unsubscribe() is good.

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

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


More information about the openjfx-dev mailing list