Es6: ability to call custom methods on set/update/delete of object properties?
-
30-06-2021 - |
Domanda
I believe I've read that the upcoming ES6 definition enables calling custom definable methods when an object property is set, updated or deleted. However, I can't find the blogpost anymore to back that up.
Is this correct? I believe this functionality was called 'proxy', although I can't find anything conclusive.
Moreover, would this be available now using es6-shim? ( https://github.com/paulmillr/es6-shim) Perhaps I'm looking for the new Map-functionality, but again I'm unsure.
Anyone can point me to a definitive pointer?
Soluzione
Yes, it is Proxy
. It is available right now in Firefox.
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Proxy
Though I do not know if its semantics match that of the proposed ES-6 Proxy.
http://wiki.ecmascript.org/doku.php?id=harmony:direct_proxies
To test the proposed standard, this is currently implemented in Chrome, but you need to enable the "experimental" features.
There are some high-level descriptions of new features being documented here, http://tc39wiki.calculist.org/es6/ but it is a work in progress.