Looking at content bindings at the same time as regular bindings makes a lot of sense, as long as the proposed changes don't result in the loss of any well-defined, workable functionality (e.g., tightening the restriction that a property P1 that is unidirectionally bound to another property P2 cannot also be bound bidirectionally to a property P3 is not a loss of any "workable" functionality).

I'll need a little more time to look at the API implications of your proposed changes (and questions) for content bindings. One thing to keep in mind is that content bindings are often created via the "Bindings" utility class, for which the object to be bound is a plain List or Map (not an Observable). That likely has something to do with the reason for the unbind methods in the properties taking an Object rather than an observable.

-- Kevin


On 7/24/2021 7:02 AM, Michael Strauß wrote:
There has been some discussion in this PR
https://github.com/openjdk/jfx/pull/533 on the semantics of
unidirectional and bidirectional bindings.

I think we've come to the understanding that unidirectional and
bidirectional bindings cannot be meaningfully used at the same time,
and such usage should be specified to be illegal and fail fast.

I think the same argument is true for content bindings, which should
mirror the semantics of regular bindings.

1. Let's look at the API of regular bindings:

void bind(ObservableValue)
void unbind()

void bindBidirectional(Property)
void unbindBidirectional(Property)

It makes intuitive sense that unbind() does not take an argument,
because there can only be a single unidirectional binding at a time,
while unbindBidirectional(Property) needs to know which bidirectional
binding should be unbound.

2. Now let's look at the API of content bindings:

void bindContent(ObservableList)
void unbindContent(Object)

void bindContentBidirectional(ObservableList)
void unbindContentBidirectional(Object)

It's a bit unclear why unbindContent(Object) requires an argument, let
alone of type Object. Mirroring regular bindings, we could potentially
introduce a new method unbindContent() without an argument, and
deprecate the other method not for removal.

In the case of unbindContentBidirectional(Object), I'm not sure why
the method doesn't accept an argument of type ObservableList. Can
someone educate me if there is a reason for this seeming inconsistency
with bindContentBidirectional(ObservableList)?`

If there is no reason for the Object argument, "fixing" this would
obviously be more problematic because it would be a
binary-incompatible change.

Reply via email to