Thanks for suggestions. Setters should allow me to fire actions when property is changed, but I still need to detect when property is added.
>From my read of http://www.nczonline.net/blog/2011/09/15/experimenting-with-ecmascript-6-proxies/ this could be done with Proxies. The third comment says: > Actually, you can hit Proxies in V8, it’s just behind a flag. Are Chrome Canary builds compiled with support for proxies? I was unable to find a flag that would enable them. On Thu, Dec 1, 2011 at 2:18 PM, Jake Verbaten <[email protected]> wrote: >>> But how do I keep DOM nodes in sync with object? Is there a way to >>> watch object for changes and fire a callback when object's >>> property is modified/added/removed? > > > There is no way to watch objects. The best way to do this is wrap your > object in some kind of watcher > > function watcher(obj) { > return { > set: function (key, value) { > obj[key] = value; > fireDOMChange(); > }, > get: function () { > return obj[key]; > } > }; > } > > The other option is periodical polling on objects or using propitiatory > api's like firefox's watch. > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/[email protected]/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/[email protected]/ > > To unsubscribe from this group, send email to > [email protected] -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/[email protected]/ To search via a non-Google archive, visit here: http://www.mail-archive.com/[email protected]/ To unsubscribe from this group, send email to [email protected]
