Re: Object.observe()able properties on the web platform

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