Show HN: ES7 Decorator library adds types checking, memoization, and more to JS
1–10 of 43 posts
Re: Show HN: ES7 Decorator library adds types checking, memoization, and more to JS
#2Re: Show HN: ES7 Decorator library adds types checking, memoization, and more to JS
#3Re: Show HN: ES7 Decorator library adds types checking, memoization, and more to JS
#4Re: Show HN: ES7 Decorator library adds types checking, memoization, and more to JS
#5Can someone recommend a simple and easy-to-approach tutorial into ES7 decorators? I have used decorators successfully in my previous Python projects, and I'm eager to start using them in JS. Unfortunately, I haven't yet come across a good guide till now.
You can enable experimental es7 features: https://babeljs.io/docs/usage/experimental/
Re: Show HN: ES7 Decorator library adds types checking, memoization, and more to JS
#6Is 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.
Re: Show HN: ES7 Decorator library adds types checking, memoization, and more to JS
#7If we were doing classes/functions the old imperative style, we could have simply wrapped the RHS in a standard function that does what the decorator does.
Animal.prototype.speedup = typeCheckDecorator("number", "number", function(x) {
this.speed += x;
return this.speed;
});
I get that the class syntax makes things easier for people coming from other languages. And maybe makes static analysis easier. But still not sure if it was really needed.Re: Show HN: ES7 Decorator library adds types checking, memoization, and more to JS
#8[deleted]
Re: Show HN: ES7 Decorator library adds types checking, memoization, and more to JS
#9Is 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.
Re: Show HN: ES7 Decorator library adds types checking, memoization, and more to JS
#10Is 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.
No these aren't the same as proxies. ES7 has class decorators that can only be used on class methods.