-
Notifications
You must be signed in to change notification settings - Fork 27
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
Can't use ES6 class as View #194
Comments
hey @PaulMaly, this topic and discussion will probably need to be turned into a wiki or added to the docs here's the situation. ES6 classes are technically not difficult to support* in domvm. they actually were supported at one point. however, domvm intentionally avoids requiring the use of * if ES6 classes are supported, the calling convention of all functions would have to change based on whether the the view is a class or not, so that class MyView {
diff(vm, data) {
vm === this;
}
render(vm, data) {
vm === this;
}
} rather than class MyView {
diff(data) {
this;
}
render(data) {
this;
}
} The thing is, everything you can do with ES6 classes, you can do better with composition using [1] http://justjs.com/posts/this-considered-harmful |
i've added this to the docs: https://github.com/leeoniya/domvm#es6es2015-classes while i don't believe there's a compelling reason for adding support for ES6 class views, i'm open to being convinced otherwise. i'm going to close this issue but feel free to continue the discussion here. i'll reopen it if there's a use-case than cannot be cleanly handled by the current architecture without classes. fwiw, React parity is not one of this project's goals. if you'd like something like domvm but more react-like, take a look at https://github.com/thysultan/dio.js |
Some strange restriction I found. I can't just use ES6 class as DomVM view even if class has render() method. Could you please provide more info about this problem? Thanks!
The text was updated successfully, but these errors were encountered: