nbrugger-tgm / reactj

A reactive ui lib for easy MVC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature] Observer

nbrugger-tgm opened this issue · comments

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]