RFR: JDK-8304439: Subscription based listeners [v2]
John Hendrikx
jhendrikx at openjdk.org
Tue Apr 18 00:14:55 UTC 2023
On Mon, 17 Apr 2023 23:42:10 GMT, Nir Lisker <nlisker at openjdk.org> wrote:
>> John Hendrikx has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Move Subscription method for invalidations to Observable
>>
>> - moved Subscription class to the Observable package
>
> modules/javafx.base/src/main/java/javafx/beans/Subscription.java line 85:
>
>> 83: other.unsubscribe();
>> 84: };
>> 85: }
>
> This looks like a special case of the `of` method:
>
> default Subscription and(Subscription other) {
> return of(this, other);
> }
>
> although this implementation creates an array, which might be what you're trying to avoid.
I think having both the "combine" / "of" method and this "and" method gives you a bit of flexibility. Sometimes you may already have a subscription, then calling:
subscription = subscription.and(otherSubscription);
... is nicer than:
subscription = Subscription.combine(subscription, otherSubscription);
When creating a list of subscriptions, `Subscription::of` / `Subscription::combine` is going to be nicer than having to chain multiple `and` calls.
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1069#discussion_r1169369137
More information about the openjfx-dev
mailing list