Using bindable events - xshley/binding GitHub Wiki

Now, we can listen for changes on the bindable and any changes made on it, or any strongly references bindables will propagate and call this value changes

Bindable events

Starting with directly on the main bindable. the same can be done with any bound bindable and it will listen and always propagate the same changes.

bindable.onValueChanged((event) -> System.out.println("Intercepted! [bindable] -> (" + event.getOld() + " -> " + event.getNew() + ")"));

We can also read Semi-Immutably from the "Weakly" bound bindable we created called "watcher" and any changes made on bindable or bindable1 will call this value, and propagate to this bindable but changes made on this watcher bindable will not propagate to the other bindables.

watcher.onValueChanged((event) -> System.out.println("Intercepted! [bindable] -> (" + event.getOld() + " -> " + event.getNew() + ")"));

Strong Watcher

bindable2.onValueChanged((event) -> System.out.println("Intercepted! [strong] -> (" + event.getOld() + " -> " + event.getNew() + ")"));

Now if we make a change to either bindable or bindable1 or bindable2 it will make a change that will affect all our bindables

bindable.set(20.0f);
bindable1.set(24.0f);
bindable2.set(25.0f);