Save Object.observe()! (please) + make WeakMap/WeakSet observable.
Tom Van Cutsem
tomvc.be at gmail.com
Wed Nov 4 22:01:01 UTC 2015
2015-11-04 0:22 GMT+01:00 Coroutines <coroutines at gmail.com>:
>
> With Object.observe() you get a global view of events generated by the
> target object, with Proxy you need to replace references to the target
> object with references to the Proxy.
>
> Now I'm changing my opinion again. We need both.
>
I won't speak to whether we really need both, but your analysis that they
cater to different use cases is correct:
- O.o allows one to asynchronously observe (not intercept) operations on
another one's objects. This is safe.
- Proxies allow one to synchronously intercept operations on one's own
objects. This is safe.
- Proxies can obviously also be used to just observe one's own objects. As
an existence proof, I once did a simple O.o polyfill using proxies <
https://github.com/tvcutsem/harmony-reflect/blob/master/examples/observer.js>.
This is not generally useful though.
- Proxy.startTrapping would allow one to synchronously intercept operations
on another one's objects. This way lies madness. Don't go there.
Cheers,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20151104/20beaa19/attachment.html>
More information about the es-discuss
mailing list