Observable

Table of contents
  1. Properties
  2. Observable Lists

This section showcases the different types of observables in the BGW framework. Observables are used to enable listening on changes of element properties.

Properties

Properties represent an attribute that notifies all listeners if it gets changed. A listener can be added by Property#addListener or Property#addListenerAndInvoke which also invokes it with the given value. Note that the given value is not set to the backing field. Every time the value of this observable is set it invokes all listeners if and only if the new value is not equal the old one. If all listeners should be invoked with the current value, use Property#notifyUnchanged.

For common data types there are dedicated classes:

For generic types use the baseclass [Property][PropertyKDoc].

The LimitedDoubleProperty behaves like a DoubleProperty but throws an IllegalArgumentException is a value is set that exceeds its bounds given as constructor parameter.

The framework uses equivalent ReadonlyProperties for one way communication. These come in the same variety:

Observable Lists

The ObservableList work exactly like Properties. It provides all standard list operations and notifies listeners every time the list changes. In the BGW framework there exist two implementations of the abstract ObservableList: