5 ms·
Vue v3.0.0-RC.1
- pritambarhate 6y agoFor those who use Vue regularly, are there any breaking changes in Vue3? How easy it is to upgrade from Vue2 to Vue3? Can one just upgrade the version in package.json and start using vue3 for new components?
- tqkxzugoaupvwqr 6y agoVue 3 introduces breaking changes, e.g. filters and event bus ($emit, $on, $off) are removed as far as I know. The Vue documentation team will release a migration guide when Vue 3 is released.
- hactually 6y agoWait... How did they remove emit? Didn't they just make it an instance level export, like props?
- fermigier 6y agohttps://tkacz.pro/vue-js-why-event-bus-is-bad-idea/ https://tkacz.pro/vue-js-why-event-bus-is-bad-idea/ https://dev.to/chenxeed/be-prepared-to-migrate-your-vue-app-to-vue-3-eom https://dev.to/chenxeed/be-prepared-to-migrate-your-vue-app-...
- culturedsystems 6y agoIt doesn't look like $emit is removed, just the functions to bind event handlers on a component ($on, $off, $once): https://github.com/vuejs/docs-next/pull/167/files https://github.com/vuejs/docs-next/pull/167/files
- IgorPartola 6y agoWhy would they do that? Having an event bus can be incredibly useful.
- mmis1000 6y agoAnd also incredibly messy, often result in non maintainable code. For one shot small project, this is fine. For a big complex project, If you see they already use this. You are mostly already screwed.
- IgorPartola 6y agoSo the way I’ve been using it is pretty much for toaster notifications and asynchronous updates that are sent from the server to the client. Any component can subscribe to async updates on the shared bus and it will know when a particular object has been updated and can choose what to do with it. We don’t use the global store for all the objects because we deal with a lot of large page-specific state. Toaster notifications are also really nice this way: a lowly modal can send a top page “an error happened” notification without having to do the plumbing for this through every page and component. I don’t see any of that as an anti pattern.
- mmis1000 6y agoAnd FB suffered from this due to undebuggable double notification bug because it could be really hard to debug when any component can send any event to other without any restriction. They eventually moved to flux pattern due to this. That said. It is possible to avoid such situation with strong lint rule. Like you did here. But you can avoid it completely with ~~JUST DON'T~~ . Why should a framework encourage people to do bad things?
- IgorPartola 6y agoUm, no. That’s the whole thing is that the components don’t have to know how it is implemented. They do this.$bus.showError(‘Oops’). The bus implementation under the hood sends a message to the top level App component which in turn has the toaster notification implementation. I don’t need a linter to make this work.
- joshstrange 6y agoAnother comment says something similar but I'll restate it. `$emit()` is still available on components and parents can still listen for them, this is just removing it from the `Vue` instance so that people don't create global (or scoped) event busses (which thankfully I don't do). You can still do // Child myFunc() { this.$emit('thing-happened', {}); } // Parent <child-component @thing-happened="reactToThing" /> They are even adding the ability for the child to define what types of events they emit (I'm super excited for the autocomplete possibilities for this and how people implement it in TS) and add validation logic to the events they define (like not emitting if the data isn't valid/in the right state). I got REALLY worried/confused when I saw the parent's comment because I was so confused at how to alert the parent of something in the child but it looks like everything is fine. This page sums it all up well: https://v3.vuejs.org/guide/migration/events-api.html#overview https://v3.vuejs.org/guide/migration/events-api.html#overvie...
- tqkxzugoaupvwqr 6y agoThe migration guide and list of breaking changes is already up: https://v3.vuejs.org/guide/migration/introduction.html#breaking https://v3.vuejs.org/guide/migration/introduction.html#break...
- zubairq 6y agoI tried to upgrade from vue 2 which using the minimized cdn js but couldn’t get it to work. Is there a minimized version of the vue 3 code somewhere that I could try?
- speedgoose 6y agoYou should minimize it yourself in your build pipeline.
- zubairq 6y agoOk, I'll wait until they release a minimized version of Vue3 then. Thanks
- bynormous 6y agoIt's mostly backward compatible, it depends on how complex your project is and what dependencies you rely on. Simple projects should be fairly straightforward - If you rely on the EventBus install mitt instead, will take you maybe 10 mins to replace. Rewriting your filters so they are plain methods instead should also be straightforward.
- jedisct1 6y agoIs there a way to use Nuxt with Vue 3?
- tpetry 6y agoVue 3 is not even released... Give them a few weeks after the release to update everything.
- Semaphor 6y ago> We have started several branches (webpack5, next, vue3) and so far Webpack SSR support for Vue3 landed but not a precise timeline for beta testing at the moment. As many internals including vue-app and builder is to be rewritten from scratch to align with vue3. (of course with less breaking changes as much as possible) -- https://github.com/nuxt/nuxt.js/issues/5708 https://github.com/nuxt/nuxt.js/issues/5708
- mcjiggerlog 6y agoIt looks like Vue 3's single file components share quite a lot in common with Svelte. As someone who has mostly only worked with React over the past few years - can anyone shed any insight on how they compare? Advantages/disadvantages? From a cursory look it looks like Svelte's greenfield approach has led to cleaner code, though it might just be my React experience speaking.
- kevmo314 6y agoVue (and React) aren't compilers like Svelte. The real advantage of using a compiler is that more complicated state changes can be instrumented without hacky introspection, which is probably why Svelte feels cleaner. The big tradeoff is that it forces the use of the Svelte compiler. Which doesn't sound all that bad until you want to use something like TypeScript and realize that it's maybe a bit odd that a framework now has a tight grip over what language/tooling is used. It seems like Svelte just recently finished their TS support, but I tried Svelte and while I liked the concept, the overreaching felt like at that rate I'd rather use ReasonML or something because Svelte JS is technically not JS, just looks a lot like it.
- ballenf 6y agoThe svelte creator talks extensively about this on a recent Software Engineering podcast: https://www.se-radio.net/2020/03/episode-402-rich-harris-on-the-svelte-javascript-framework/ https://www.se-radio.net/2020/03/episode-402-rich-harris-on-...
- Can_Not 6y agoCleaner code, maybe if you can ignore that Vue and React have superior support for error handling.
- georgecalm 6y agoYesterday’s thread on the RC release: https://news.ycombinator.com/item?id=23875541 https://news.ycombinator.com/item?id=23875541