Use ScenePulseListener to avoid expensive recalculations?
tomas.mikula at gmail.com
Thu Nov 7 05:08:25 PST 2013
On Thu, Nov 7, 2013 at 11:58 AM, John Hendrikx <hjohn at xs4all.nl> wrote:
> Hm, I found it googling, and since it showed up here:
> I figured it was public, but I just noticed the class is defined package
Although not part of the public API, you can use
Anyway, I don't think deferring property invalidation until the next
pulse is very useful in general, for the following reasons:
1) It can lead to inconsistent observable state of your objects.
Consider an object with properties p, q, where the value of q depends
on the value of p, and consider changing the value of p. Now, right
returns, the state of the object is inconsistent until the next pulse,
and this inconsistency is observable to the outside world.
2) It doesn't (in general) avoid recalculations. Consider properties
p, q, r, s, whose invalidation listeners are deferred until the next
pulse, with bindings
p <- q <- r <- s
p <- s
and consider changing the value of p in pulse 0. The invalidation
listeners will fire as follows:
pulse 1: p
pulse 2: q, s
pulse 3: r
pulse 4: s
As you see, the listeners of s are called twice, causing potentially
For these reasons, I'm in favor of the approach suggested by Yennick,
where you "commit" the properties yourself.
More information about the openjfx-dev