Polyfilling Object.observe
T.J. Crowder
tj.crowder at farsightsoftware.com
Tue Jul 24 17:17:02 UTC 2018
On Tue, Jul 24, 2018 at 6:01 PM, /#!/JoePea
<joe at trusktr.io> wrote:
> Is there a way to polyfill `Object.observe` in such a way that the object
> before observation is the same reference as the object being observed
after
> the call (i.e. not a Proxy), and other than monkey-patching
getters/setters?
>
> Is defining getters/setters the only way?
Even that doesn't really polyfill it, because `Object.observe` got
notifications of changes when new properties were created as well.
But yes, **if** you know the names of the properties in advance (the
"shape" of the object, I believe, is the current parlance?), and if you
want notifications of changes just to those properties, I think
monkeypatching will be your simplest and most successful approach.
If you need to catch additions as well, I don't think there's any solution
other than diffing, which is quite yucky.
-- T.J. Crowder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180724/873c1717/attachment.html>
More information about the es-discuss
mailing list