128 points · by calibas · 6y ago · 27 comments
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-...