Vue v3.0.0-RC.1
github.com
github.com
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.
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?
It `is` fine to use it and only use on notification purpose, but there is no way to enforce everyone to do so.
More of time it `will` be used in a terrible way that I just described (something like .emit('login') and trigger some random function causing xhr and emit notification everywhere).
You can't really assume everyone will use them nicely instead of resulting in spaghetti code. It is not the case most of time.
The experience I learned from I start coding is. `Anything designed to be easy to mess up will eventually mess up`
Basically, it’s not like they added a formalized way to create notification buses. They simply removed a useful and widely used feature because they didn’t like how people were using it. This is exactly the kind of shit that killed Angular and honestly makes me reevaluate the trust I’ve placed in Vue. Improvements are always welcome. Wholesale removing useful features without providing an alternative, not so much.
Moreover, You can polyfill it simply in one line. And it actually exist long before the vue ever exist.
const { EventEmitter } = require('events').
It always make me wonder why was vue ever want to pack this into itself given it did not use it as all.
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#overvie...
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.
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.
https://www.se-radio.net/2020/03/episode-402-rich-harris-on-...