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...
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.