-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
using object factory and class factory to support class component #2689
Comments
see https://github.com/vuejs/vue-class-component |
Vue 3 supports typescript out of the box. It doesn't require class or decorator usage but you can with the mentioned libraries if you want to. |
@posva I do not care about and by the way , the and @posva have you try to write a vue3 app that fully use typescript ? and have you try react or Angular ? don't you think that with typescript vue core, it's still hard to fully use typescript to write vue (you can but does the type system in typescript provide any advantage? or just became a burden) please consider the possibility of this proposal instead of reject this immediately , because this won't effect current js like api // mixed factory
if(component instanceof Object){
ObjectFactory.doItsWork();
}
else{
ClassFactory.doItsWork();
} |
The things you propose have been discussed already and that's why there is an officially supported library vue-class-component. As a maintainer, I would appreciate if you search existing RFCs https://github.com/vuejs/rfcs before opening this kind of proposals, it would really save us time 🙂 |
I can also understand your thoughts very well. For back-end development, using classes, factories, decorators, etc. has become a habit (I am also very inclined to your opinion). Vue3 also tried the class api at the beginning, but finally gave up, partly because there are many features that are still in the proposal stage and are unstable, such as decorators. The class api can be seen in the initial code submission. Perhaps these ideas you mentioned will be added in a future version.Angular has better support for typescript, more like a strongly typed language. But the cost is too high for beginners. After all, there are still relatively few masters like you. |
You can take a look at this if you are interested. vuejs/rfcs#17 |
|
I also prefer |
@edison1105 sorry that I |
oh~ ,this is more embarrassing.😆😆😆 |
What problem does this feature solve?
vue3 is writing using typescript , but it seems your team do not want we to use typescript to write vue app, today it's harder to use typescript with a non-class style object data define to define a component. and I don't know why your team is reject typescript as your first class language support. and maybe because the metadata standard not finish yet, but I want to say is that without metadata support in ES we can even use it now , that means that no matter what happened , metadata work for now will work tomorrow too !
and my idea is to use a factory to get component, if you do not want the metadata then make the factory can be replaced. eg. default vue3.js only use object component factory, and with class support library , that replace with a two type factory (class factory + object factory).
why use a factory ?
because we can stop map class to object and then we can get a clear class component without mix the object component behaviors.
in object component (I called it data configure style instance) , you try to hide the lifetime method, and in class there are no need ( the factory active the method and any lifetime stuff is doing in factory instead of class lifetime ).
ts
and for js users
the good thing with type component
with
ref
componentother change
mixin
andvuex
repalce withservice
(maybe we need rxjs to resolve the changing event).using
What does the proposed API look like?
The text was updated successfully, but these errors were encountered: