class dataset {
__data__={};
__actions__ = {};
__data__ = new Proxy(this.__data__,{
set(target,prop,val){
this.__actions__[prop]?this.__actions__[prop]():'';
target[prop]=val;
},
get(t,p,r){
return t[p];
}
});
setData(prop,val){
this.__data__[prop] = val;
}
getData(prop){
return this.__data__[prop];
}
watch(prop,action=()=>{}){
this.__actions__[prop] = action;
}
}
x = new dataset;
x.parent=dataset;
x.setData('name','satyam');
let y = x.getData('name');
console.log(y);
I can't get the scope of the dataset class in the Proxy to get actions.
I am trying to make an class which takes an corresponding action when data in it is changed