W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2014

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

From: Domenic Denicola <domenic@domenicdenicola.com>
Date: Wed, 20 Aug 2014 19:03:13 +0000
To: Olli Pettay <olli@pettay.fi>, 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>
Message-ID: <1408561393368.83239@domenicdenicola.com>
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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:22 UTC