Closed CodersBrothers closed 11 years ago
your variable "a" need to be associated to a parent object it is impossible to do such a thing even with this other library
this will work:
var obj = {
a: []
}
watch(obj, "a", function(){
console.log('Something');
});
obj.a.push('hi');
Its awfull that cannot do something like this var a = []; watch(a, function(){ console.log('Something'); }); a.push('hi');
But its really awfull when you put something like: var a = { b:[ { id: 1, name: 'qqqqqqqqqqqq' }, { id: 2, name: 'rrrrrrrrrrr' } ] }; watch(a, function(){ console.log('Something'); }); console.log(a.b);
¿Where is the values?
I changed to use this library, maybe author can get ideas: https://github.com/jdarling/Object.observe