Hacker News new | ask | show | jobs
by thomasfoster96 4035 days ago
Is something similar to this possible with ES6 proxies? It'd be nice to use a lot of these features outside classes, but since proxies are far harder to polyfill (indeed, I don't think anyone's some it yet) I've only seen then done with decorators within classes.
4 comments

I once implemented type checking in ES5 as a proof-of-concept: https://github.com/panuhorsmalahti/typed-javascript
you dont need proxies, here is how decorators work and how you can implement them yourself, without the syntactic sugar obviously

https://github.com/wycats/javascript-decorators

Proxies are an entire different thing.

No these aren't the same as proxies. ES7 has class decorators that can only be used on class methods.
I know they're not the same, but I'd love to be able to use some of the thins I can use with decorators, but on plain objects.
You can also use them on class declarations themselves and object literals - https://github.com/wycats/javascript-decorators#object-liter...
es7 decorators can also be used on vanilla objects, not just classes.
Really? Any tutorials/posts/examples of using them on plain objects anywhere?
Yeah, check some of the examples in the readme