RFR: JDK-8303897 ObservableValue's when binding should only invalidate when strictly needed [v2]
John Hendrikx
jhendrikx at openjdk.org
Sun Apr 9 21:27:37 UTC 2023
On Sun, 9 Apr 2023 20:53:48 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:
>> That's not really useful as there is no way to make such a fluent binding valid again (it would invalidate once, and never become valid). The only way to make it valid would be to assign the result of `map` to a variable, and call `get` on that.
>>
>> I can however add a test that proves the above :)
>
> Also, the test is specifically looking how often `map` is called here (which is triggered by invalidations from the `when`). The listener is only there to make sure that `map` has installed its listeners as fluent observables don't install them when not observed themselves. I could have used an `InvalidationListener` here for this purpose, but then I'd still need to call `getValue` on the `map` observable as otherwise it will definitely not map anything as it is invalid.
>
> Perhaps a simple test that shows this is the case can be useful.
I've added a variant with an InvalidationListener directly on the when binding. It works as I would expect, it's maybe a more useful test than the others (it basically tests the same thing, but more directly).
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1056#discussion_r1161342589
More information about the openjfx-dev
mailing list