Hi,
I want to trigger an event handler when a property changes.
If the property is set via a function, it's simple to trigger the
attached event handler.
But if the property is set directly, I don't know how.
What I want is like the property in C#.
var obj = new MyClass;
obj.onNameChange = function() {...}
obj.name = "Sam"; //<= I want to triger obj.onNameChange automatically.
If this is via a function:
var obj = new MyClass;
obj.onNameChange = function() {...}
obj.setName("Sam"); //<= I can trigger an event handler in the
function.
I hope I described what I want well.
Thanks.
Sam