[Feature] Observer
nbrugger-tgm opened this issue · 0 comments
nbrugger-tgm commented
Creating a more abstract implementation of the ReactiveController
would allow users to add custom Observers.
Example
ReactiveProxy<Data> model = ReactiveObject.create(Data.class);
Data d = model.object;
Observer<ReactiveModel<Data>> observer = new Observer<ReactiveModel<Data>>() {
@Override
public void onChange(String property, Object value) {
System.out.println("Property "+property+" changed to "+value);
}
};
observer.bind(model.reactive);
d.setA(10);
d.setB(20);
d.setD("Some value");
d.setD(Color.BLUE);
Output
Property a changed to 1
Property b changed to 2
Property d changed to java.lang.Runnable@61e717c2
Property a changed to 10
Property b changed to 20
Property d changed to Some value
Property d changed to java.awt.Color[r=0,g=0,b=255]