Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move component methods out of constructor #139

Closed
PaulBGD opened this issue Dec 7, 2016 · 4 comments
Closed

Move component methods out of constructor #139

PaulBGD opened this issue Dec 7, 2016 · 4 comments

Comments

@PaulBGD
Copy link
Member

PaulBGD commented Dec 7, 2016

Instead of doing this.fire =, this.get =, etc we should move the component methods out of the constructor.

@Rich-Harris
Copy link
Member

I'm not sure that's strictly true – with class, various private variables (callbacks, observers, mainFragment etc) would become properties of this, at which point you can't minify them (though the difference is small after gzip). And because a lot of people would still need to transpile class syntax, you'd be introducing both build time and run time overhead.

That said, there are some benefits to moving component methods out of the constructor, particularly when we get round to externalising methods and helpers that can be shared between components.

@PaulBGD PaulBGD changed the title Generate Class Syntax Move component methods out of constructor Dec 7, 2016
@PaulBGD
Copy link
Member Author

PaulBGD commented Dec 7, 2016

That works too, I'm just complaining because closure-compiler doesn't seem to like assigning methods to this.

@Swatinem
Copy link
Member

Swatinem commented Dec 7, 2016

There is already work towards this goal in #37, in the first place for the generated template code.

@PaulBGD
Copy link
Member Author

PaulBGD commented Dec 7, 2016

@Swatinem Yeah, I guess when I changed the direction of the issue it made it a duplicate.

@PaulBGD PaulBGD closed this as completed Dec 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants