I didn't make it clear, but Object.defineProperty with getters and setters gets rid of angular.js's traversal needs (I assume, having only looked at angular quite a while ago). There's a few different ways I can think of doing it, I'm just wondering if anyone has yet.
And it also gets rid of the need to hide all your properties in an attributes collection. I'm not sure why you think that's good because it doesn't fire events.
And if you really need ignore properties, you could do something like this:
var Person = {};
Person.prototype = new Model;
var bill = Person.create({ name : "Bill", email : "bill@example.com" }); //adds all using defineProperty and a watcher in get, set functions
alert(bill.name); //Woo, alerts "Bill", not undefined!
bill.name = "Bob"; //event fires
person.special = "blah"; //wouldn't be watched as it's been added after creation
person.addProperty("special2", "blah2"); //would be watched
person.special2 = "blah3"; //events now fire with 'normal' access
var person2 = Person.create({ name : "Bill", email : "bill@example.com", special : "thing" }, { ignore : ["special"]}); //special is not watched
You could even do the opposite and tell it exactly which properties to even bother watching.
There's a reason getters and setters have been added to js, and it's for exactly this kind of thing!
And it also gets rid of the need to hide all your properties in an attributes collection. I'm not sure why you think that's good because it doesn't fire events.
And if you really need ignore properties, you could do something like this:
You could even do the opposite and tell it exactly which properties to even bother watching.There's a reason getters and setters have been added to js, and it's for exactly this kind of thing!