The “Observer Pattern”
#The key element in how JavaFX achieves Reactivity is via a set of objects which implement the “Observer Pattern”. Fundamentally, this is a hierarchy of classes which allow you to create an observable wrapper around virtually any data type. Along with that comes all of the structure that you need to connect them to each other so that a change in one observable object triggers changes in other observable objects.
When you are working with Observables, you tend to be concerned with establishing the connections between them. This means that the code that you write is configuration code that happens when the Observables are created. And since almost all of the uses that you’ll have for them in the GUI are expressed via Observables baked into the Nodes, this means that you connect them to the Node Properties and then forget about them.
The Observable library is extensive, extensible and has massive functionality. This means that it can be a challenge to learn how to use it properly.
Just like the Nodes, there are a large number of classes and interfaces that extend from a single parent class. This is the Observable interface. This includes the ObservableList and Property interfaces which are used extensively in just about any JavaFX application.
In this section, we are taking an in-depth look at all things observable in JavaFX. You can get a long way just by reading the first two articles here. If you want to achieve comprehensive understanding about how the entire library hangs together, there are several articles in the section called “Guide to the Observable Classes”.