2015-11-04 0:22 GMT+01:00 Coroutines <[email protected]>: > > 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
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

