RFR: 8290040: Provide simplified deterministic way to manage listeners [v7]
John Hendrikx
jhendrikx at openjdk.org
Wed Oct 26 07:39:45 UTC 2022
On Wed, 19 Oct 2022 20:56:43 GMT, Nir Lisker <nlisker at openjdk.org> wrote:
>> Does `asLongAs` imply recurrent nature?
>
> I don't see why not.
About `Bindings.when` confusion:
`Bindings.when` serves a different purpose. `Bindings.when(condition).then(x).otherwise(y)` is the same as `map(condition ? x : y)`. The fact that it uses "when" and "otherwise" is more because "if" and "else" are unavailable.
`when` has the implication of it being a near certain event somewhere in the future, and IMHO was never a good match for `Bindings.when` but there was little choice when naming such a construct.
In `ObservableValue` I think `when` is a name that is quite a good match to describe its purpose in fluent bindings; it is not used for a simple if/else condition that may never be `true` or `false` like it would be in a simple `map`, but for a condition that **will** change in the future. Why do I say this? `when` doesn't change the source value, only passes it through. If the condition would never change in the future, then there is no point in using `when` -- you could either just always pass it through, or always map it to the empty value -- so when a binding uses `when` it is a near certainty that the condition changes at some point in the future.
-------------
PR: https://git.openjdk.org/jfx/pull/830
More information about the openjfx-dev
mailing list