Boolean operations allow you to incorporate conditions directly into the binding.
First of all, there are BooleanExpression/BooleanBinding classes to represent observable boolean values. Then, to make if-then-else condition handlers, there are special methods in the Binding API:
when( CONDITION ) -> then( A ) -> otherwise( B )
Here, when, then, and otherwise are actual method names, not pseudocode. This construction means the following:
- Listen to A and B
- If A is changed and the CONDITION is true, update the bound value with A
- If B is changed and the CONDITION is false, update the bound value with B
As an example, let's forget for a minute we have the min() method from the rectangles grid example and re-implement it using ...