Reputation: 786
Hi Initially I have created empty javascript object ,
var obj = {}
I have push two different values to object from different function I need to trigger any event when object has value, for example if value pushed to object then I need to trigger any event and I saw object.watch() but it is not suitable for me, I dont know my question is wrong or write anyone suggest me for my problem
Upvotes: 1
Views: 141
Reputation: 138457
var obj=new Proxy({},{
set(obj,prop,value){
alert("setting "+prop+" to "+value);
}
});
Simply use an ES6 Proxy ( reference)
Upvotes: 1