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

From: Olli Pettay <olli@pettay.fi>

> How would you implement observable properties efficiently?

The efficiency is already solved by the Object.observe implementation. 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:03:52 UTC