Earlier quoted context omitted.
You can do complicated things with Svelte stores, but in my experience most of the time you only need something like this using a writable store: import {writable} from 'svelte/store'; const person = writable({name: 'Mark', zip: 63304}); function handleChange(event) { const name = event.target.value; person.set({...$person, name}); } Hello, {$person.name} at {$person.zip}! Of course if person is only used inside this…
Right but this is still a lot of code for changing the name of a person. Also, this works with pojos and primitive values. What happens when you add class instances, relationships, children, etc? For example in a project I was working I had geometrical figures in my reactive data model. With classes I could simply do: rectangle.getArea() With MobX this was super simple to implement. If I wanted to change the position…
The key is that when you update a Svelte store you must return a new value. It's enough to just return the value you updated. You see that happening here on lines 16 and 21.
I take your point that this is not as transparent as when using observables. But at least you can use classes that have relationships and call methods that modify the objects when those objects are in Svelte stores.