Google
 

Wednesday, July 11, 2007

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:

// arithmetic
var x = 10;
var y = bind -x + 100;
assert y == 90;
y = 40;
assert x == 60; // passes

Chris' blog post also contains an example for logical negation, as well as for sequence elements.

technorati tags:, , ,

1 comment:

  1. Cannot assign to a bound variable run-time error occurs when I tried this with JavaFX 1.2.

    ReplyDelete

Please comment! I look forward into hearing your comments/oppinions.