4 ms·
I miss the old options API being the primary API :(
by rokkamokka 2y ago
I miss the old options API being the primary API :(
- Satam 2y agoYeah, I don't get it. I used Vue because it was straightforward. The options interface was Vue. Now, if it keeps getting more complicated and also has two ways to go about things, and the docs are split into two as well... Why not just go for React that's complicated and more popular?
- Semaphor 2y agoI find the composition API to be clearer and simpler in almost every way. Script setup is amazing. Also proper typescript support without annoying workarounds, that alone would make it worth it.
- sampullman 2y agoI thought the composition API was clunky at first and resisted migrating for a few minor versions, but it's matured nicely. I find it much simpler than the options API, and migration was much easier than I expected. I don't see it as two ways in practice, just the legacy way for old projects (which still has good support), and the newer/better way.
- deleted 2y ago[deleted]
- rty32 2y agoWhat's the biggest Vue.js project you worked on? Asking because my experience is that as soon as you have a large and complex component that needs to have multiple, mostly independent functionalities, you'll find the composition APIs to be a godsend. Not to mention all the IDE support. You won't see that until you have first have experience with it.
- MatekCopatek 2y agoReally?? Why? I'm a long time Vue user and the new API feels like the exact same thing, just more flexible and easier to reuse.
- crabmusket 2y agoWe're currently going through a migration of writing new components in composition style, but obviously have a lot of experience with the options API and a lot of existing code using it. It's taken the team some time to get used to how to do things in the new way, but on balance, we do like it. It feels like there have been some odd caveats, like the new reactivity system approach not working exactly like we'd expect. But caveats exist in the options API too.
- zmmmmm 2y agoi find it so much harder to grok the structure of Vue 3.x code. A data variable or prop can be defined literally anywhere. And it could be directly reactive or a ref. It's all cognitive load I didn't need before. Vue was always "worse" than react in both mind share and flexibility / purity and power. But it made up for all of it with the beautiful intuitive simplicity. So much of that is lost but I find it hard to argue any of the other aspects are better than React now. So Vue just feels overall a bit mediocre now. I will say, with 2.x about 50% of bugs where not using Vue.set(...) in some obscure place or way, and those have all gone away, which I love.
- dgwight 2y agoMe too. The options api enforced grouping and you could lint the ordering of the lifecycle methods, methods, computed, data etc. Thjs made it very easy to know where to find something inside a component
- conradfr 2y agoThat's why I still use it, it's so quick to find things when you open a component. The tutorial and reasoning about the composition api make sense ... but I never feel I need it in my own apps.
- rty32 2y agoGrouping is good until you have a UI component that needs to do 3 different things. It will be a mess because everything is mixed together. See official example: https://vuejs.org/guide/extras/composition-api-faq.html https://vuejs.org/guide/extras/composition-api-faq.html . This has been tremendously useful for developing large components. If you haven't found a need for this, great for you. Options APIs will also continue to be available for the foreseeable future. But that doesn't mean it is better in any way.
- holistio 2y agoI had the same vibe and I still have it regarding Nuxt 3. Had it with React when it moved to functional components from class components. But I convinced myself I have to dive deep enough to understand it since a lot of people seem to like it. And now I like the Composition API more in general. Apart from one tidbit: I constantly forget where I need to put `.value` after a variable name to extract its... value.
- euoia 2y agoThe .value thing is dreadful. Is it really necessary? I still prefer options API.
- lloydatkinson 2y agoIt really is awful and smells of leaky abstraction. Now that this is the recommended way of writing Vue, I’d be really interested in your opinion on React. Compare the “ref” in Vue with useState hook in React. With the useState you get back two items: the value, and a setter. Now every time you access the value you simply access it like a variable because it is.
- rty32 2y ago[flagged]
- lloydatkinson 2y agoWhy are you under the pretence I don’t know the difference? I clearly know the difference. I’m discussing the ergonomics of the API and its resulting DX. Sigh, I wish people put some effort into actually reading the thing before posting opinions.
- rty32 2y agoThat's just how Proxy works in JavaScript. You might want to read a bit more about the underlying mechanism.
- 2y ago
- Muromec 2y agoI blame react with their stupid hooks that are supposed to be algebraic effects. It all went downhill from there.
- h_tbob 2y agoI like the options api but what I like about the setup api is that you don’t have to import components then specify them in components property. Makes it a lot easier when doing go to source, and you can just import them automaticallly with dev tools.