andreypopp / autobind-decorator

Decorator to automatically bind methods to class instances
MIT License
1.45k stars 66 forks source link

Thoughts around using ES7 property initializers instead? #49

Closed jjmasse closed 7 years ago

jjmasse commented 7 years ago

Good morning, and thank you for this decorator - the binding of methods on components has been messy and this does a nice job in helping us clean it up.

Some of my teammates had shared this and I have been encouraging them to use ES7 Property Initializers and arrow functions instead of a decorator like this. We write a lot of React code, it has made sense to drop the dependencies and using the language to help us achieve our goals.

https://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#es7-property-initializers

In addition, we have a new bind operator - https://github.com/tc39/proposal-bind-operator which creates a more elegant solution for dealing with context control.

What are your thoughts?

stevemao commented 7 years ago

I have already added Class instance properties in alternative section. Is there anything else you want to add?

jjmasse commented 7 years ago

That is great! Thank you for considering the addition.