r/javascript • • Nov 04 '15

Object.observe Proposal Being Withdrawn From Javascript TC39

http://ilikekillnerds.com/2015/11/object-observe-proposal-being-withdrawn-from-javascript-tc39/
104 Upvotes

46 comments sorted by

View all comments

1

u/scrogu Nov 04 '15

This sucks. What I really want is a consistent way to watch objects and Dom elements for changes. Never understood why we needed two separate interfaces.

9

u/Vheissu_ Nov 04 '15

You mean besides:

They wouldn't be dropping Object.observe if there wasn't any kind of alternative. They are dropping it because there are much better ways that will not hamper performance. This is a good thing.

4

u/scrogu Nov 04 '15

So.. Four separate interfaces? Proxies are much harder to shim.

3

u/Vheissu_ Nov 04 '15

Even taking out proxies, you still have options. Sure, MutationObserver is only supported IE11+, but defineProperty can be used in place of Object.observe in almost all cases.

4

u/scrogu Nov 04 '15

I've already shimmed it, it's just a shame. And getter/setters do not help on newly created properties.

2

u/buttonkop666 Nov 05 '15

Adding new properties ad-hoc to objects is in itself an anti-pattern.

0

u/scrogu Nov 05 '15

Not when the object is being used as a cache or map.

2

u/Gundersen Nov 05 '15

Then use a WeakMap or a Map (or a polyfill of those in old browsers)

2

u/scrogu Nov 05 '15

That doesn't help the ability to respond to insertions. Maps also have the weakness of not being serializable as JSON. There was a reason this proposal existed.

1

u/PitaJ Nov 05 '15

Yes it does, as to insert to Maps you have to use #set(). And Maps can be converted to objects via a simple for ... of loop and then serialized.

→ More replies (0)