I won't be implementing a callback but you do something similar with plain old javascript.
Old code might look something like this...
var colour = window.GetProperty("COLOUR", RGB(0,0,0));
function update_colour() { // triggered by clicking a button/menu/whatever
colour = ...
window.SetProperty("COLOUR", colour);
window.Repaint();
}
You can use Object.defineProperty with your own custom getter/setter like this...
function property(name, default_) {
Object.defineProperty(this, 'value', {
get : function () {
return this.val;
},
set : function (value) {
this.val = value;
window.SetProperty(this.name, this.val);
}
});
this.name = name;
this.default_ = default_;
this.val = window.GetProperty(name, default_);
}
Updated code would be like this...
var colour = new property("COLOUR", RGB(0, 0, 0));
To "get" the value you need to use colour.value like this...
gr.FillRectangle(0, 0, 200, 200, colour.value);
Now when you update the value you can write...
colour.value = some_new_colour();
And that is it. Because window.SetProperty is inside the custom "setter", it automagically updates and if you really must you can put your notify others code inside the custom set function too.