- From: Olli Pettay <olli@pettay.fi>
- Date: Wed, 20 Aug 2014 22:16:48 +0300
- To: Domenic Denicola <domenic@domenicdenicola.com>, "Tab Atkins Jr." <jackalmage@gmail.com>, Anne van Kesteren <annevk@annevk.nl>
- CC: Jonas Sicking <jonas@sicking.cc>, Mounir Lamouri <mounir@lamouri.fr>, Marcos Caceres <w3c@marcosc.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On 08/20/2014 10:03 PM, Domenic Denicola wrote: > From: Olli Pettay <olli@pettay.fi> > >> How would you implement observable properties efficiently? > > The efficiency is already solved by the Object.observe implementation. In JS engine sure. But we're talking about DOM objects here. > My understanding is that the overhead is close to negligible for cases when nobody observes the object. > > If you are asking how you tap into that as a developer, you do something like `this._notifier = Object.getNotifier(this)` in the constructor, and then do `this._notifier.notify({ type: 'update', name: 'propertyName', oldValue: propertyOldValue })` inside the relevant setter. Obviously real implementations would not use underscored-properties, but you can see how it is very much automatable via a WebIDL binding layer. >
Received on Wednesday, 20 August 2014 19:51:40 UTC