SubjectObject
It's a simple Javascript class that implement the Subject part in a Observer-Subject relationship.
How to use
In order to create a Observable object (subject) you have to extend SubjectObject class, adding observable properties using 'createProperty' method
// Observable objectvar { SubjectObject; this; this; thisa = "..."; thisb = 12;} Fooprototype = Object;Fooprototypeconstructor = Foo;
Then you can add a listener (Observer) using 'addObserver' method:
// Observervar { } Barprototype { var property = changesproperty; console; console; console;} // Linkvar f = ;var b = ; f;
When a property of 'f' object is changed
f.a = 'Hello world';
all listeners are notified (called)
Property " a " has changed
New value: " Hello world "
Old value: " ... "