JSFiddle - React, Tailwind, and code Playground
JavaScript
function myClass(){
var _this = this,
testVal = 0;
Object.defineProperty(myClass.prototype, "testVal", {
get : function(){return testVal;},
set : function(val){
testVal = val;
_this.setTestVal(val);
}
});
}
myClass.prototype.setTestVal = function(value){
console.log("testValue set with " + value);
}
var test = new myClass();
test.testVal = 1;