Skip to content

Instantly share code, notes, and snippets.

@viT-1
Last active November 2, 2022 20:48
Show Gist options
  • Save viT-1/ad23f3daa9c637f165051f0a5c03cde2 to your computer and use it in GitHub Desktop.
Save viT-1/ad23f3daa9c637f165051f0a5c03cde2 to your computer and use it in GitHub Desktop.
#gist-bookmark #vue #class #oop

Что делать с синтаксисом, когда даже с вводом в Vue3 поддержки TypeScript из коробки, классы не выжили?

Вообще, это интересное развитие событий, когда в мажорную предыдущую версию (v2.7) добавляют новое API (Composition) фактически из новой мажорной версии (v3.0). Что называется "дать заднюю", когда предполагался задел на будущее из v2 в v3 в виде vue-class-decorator.

One catch was that the base Vue class for components needs to be imported from vue-class-component, not from the vue-property-decorator (as we had it before). It works in the actual app, but fails in tests (vue-test-utils)

Цитировано отсюда

Why not migrating to the composition api? because the options API is a completely direct, no-brainer migration. The team still doesn't have real/professional experience with the composition API (neither do I), so doing the mentioned above, and at the same time trying to figure our what is the best way to transform our code to correctly use / better leverage the composition API... again is not an option for us.

Цитировано отсюда. Разворачивается целый рынок, где можно заработать на миграции проектов с Vue2 на Vue3!!!

Highly recommend you migrate away from class components if you ever plan to migrate to Vue 3 because it appears the vue-class-component package has been abandoned and this package is complementary to that one so neither will likely ever be officially released.

Цитировано отсюда. То есть Class API предполагается оставить за Vue2, а Vue3 перевести на другие рельсы, несмотря на то, что TypeScript поддерживает классы.

@viT-1
Copy link
Author

viT-1 commented Nov 2, 2022

Внезапная смерть фреймворка от резких решений в OpenSource среде. Доходит до отказа от Vue в принципе, с целью иметь стабильное API и при этом ещё и Typescript, переезжают на Angular/React:

Their reasoning isn't sound at all, class API is more in line with the direction the web is moving, and is also far easier for developers to use. Angular, Web Components, and even React have first class (no pun intended) support for class based components. Vue randomly deprecating/removing features and having no sound strategy make it hard to justify using it in the future.

We also moved away from Vue to Angular and are currently rebuilding our components in Angular cause of that. It's sad but I also don't recommend using Vue anymore cause of decisions like that.

Im kinda ashamed to say this but as a TL this was a rookie mistake trusting in a org this young. We'll be moving to angular too for our new projects (hate my gut for this as I love class based vue and Vuex combo that Nuxt provided)

The problem is really the mentality of Vue core team, who suffered a lot of fallout from RFC when they dropped class syntax and went to composition API. A lot of toxicity was injected into discussions around the RFC and now class/decorator methodology is associated with that unfortunately.

They don't care about their enterprise consumers I guess. I'm sure by now they've realized that by alienating so many of their consumers, it's going to slow their momentum. The Vue Eco-system is very confused.

I'm not going to invest anymore time into a framework who's core team is willing to abandon core libraries with such disregard. The thing that burns me the most is that I heard Evan say he was against decorators because they were not yet part of JS and they were too magical. Meanwhile he introduces the <script setup> syntax which does exactly what a decorator on a class did and transforms the data in an object. <script setup> is not part of js either. It's also magical. That is sort of a double standard there.

I don't think you understand the severity of this entire fiasco. Im flabbergasted that more YouTubers and influencers aren't talking about this. Its the nitty gritty stuff that might not get all the views but damn I wish I had the platform to prevent someone just like me who 3 years back saw vue2 as a great option to not fall into the same pitfall again with Vue3.

The argument from Vue was that they didn't want to support 3 different ways to do the "same thing": Options, Composition, Classes which is the only substantive argument put forth from reading what little was said about it. The FAQ doesn't even try to give an argument and just unceremoniously denounces it without any justification. Quite telling about the attitude on the team towards this idea.

Отсюда

They leave and maintain the Options API, even add a switch on the docs to switch between Composition/Options APIs,
not to get Options API fanboys upset, because they knew if they forced the Composition API, there would be an outrage and boicot (and it happened anyways). But they don't care about the people who work with classes and OOP. They were quickly to deprecate it.
And before you call me on this, there doesn't need to be an explicit message saying "deprecation", when you can read between lines.

Отсюда

@viT-1
Copy link
Author

viT-1 commented Nov 2, 2022

Composition API расценивается как вкусовщина:

I've read quite a bit about the composition API, and I can't see anything that demonstrates it's superior architecture. Sure the make claims left and right about how awesome, but nothing I've read convinces me it's any better than class-based. There is a significant amount of boiler plate code composition API creates that didn't exist with class-based API. It's only "better" as a matter of taste not an objective truth.

@viT-1
Copy link
Author

viT-1 commented Nov 2, 2022

Например, есть вариант для использования Composition API но классами в Vue2 и Vue3, но когда кодовая база уже написана на обещанном API с помощью vue-class-component, то это не вариант. Но для нового проекта попробовать может и стоит, хотя кто знает насколько глубока была поддержка vue-class-component в других библиотеках (декораторах разных), да и сильна привычка декларировать компоненты как опции.

@viT-1
Copy link
Author

viT-1 commented Nov 2, 2022

Обсуждение придания статуса deprecated проекту vue-class-component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment