Bidirectional binding in JavaFX
In the next version of the JavaFX interpreter, Chris Oliver introduces a genious concept he calls bidirectional binding.
In short it means that you can now bind a value, Y, to a function of another value, X. When you change the value of X, Y changes automatically - this is ordinary binding.
The magic happens if you change the value of Y. Then JavaFX performs a reverse calculation, to rectify the value of X!!
A small example from Chris's blog:
// arithmeticChris' blog post also contains an example for logical negation, as well as for sequence elements.
var x = 10;
var y = bind -x + 100;
assert y == 90;
y = 40;
assert x == 60; // passes
technorati tags:javafx, interpreter, chris oliver, bidirectional binding
Cannot assign to a bound variable run-time error occurs when I tried this with JavaFX 1.2.
ReplyDelete