I'm trying to make a class with a large number of properties, all of which would trigger emission of an event when the instance was changed, What are some good options without creating a wall of static setters?
class MyClass {
constructor() {
this._propertyA = "";
// 50 similar properties
}
set propertyA(val) {
this._propertyA = val;
this.emitChangeEvent('myClassObjectChanged');
}
// I'm trying to avoid creating 50 setters here
}
Or maybe there is a better approach to that in general?
Edit: the suggested duplicate wouldn't work for me as I'm trying to retrofit observability on properties, basically I can only rewrite the class itself but not the whole other code that references it