Java Reference
In-Depth Information
When the parameter of the function (value assigned to param ) call is updated, the function is
automatically re-invoked and the variable squared receives the newly calculated value.
Bind to an object literal
A variable can bind to an object literal declaration. When the values of the bound object
properties change, the expression is updated with a new object.
class Location {
var x:Integer;
var y:Integer;
var xLoc = 0;
var yLoc = 0;
def loc = bind Location {
x: xLoc;
y: yLoc;
xLoc = 12;
yLoc = 234;
println ("loc.x = {loc.x}, loc.y = {loc.y}");
To avoid creating a new object every time a bound property value is updated,
bind each literal property in the object declaration separately as shown.
var xLoc = 0;
var yLoc = 0;
def loc = Location {
x: bind xLoc;
y: bind yLoc;
There's more...
JavaFX offers another event-based mechanism called a trigger. A trigger is a code block that
gets executed when the variable it is assigned to is updated. At its simplest form, a trigger is
declared as follows
def variable = value on replace [oldValueVarName]{
// code to execute
Search WWH ::

Custom Search