|
|
|
|
|
by chrisco255
1003 days ago
|
|
> create a spaghetti mess, _if your design allows it_. Svelte 5 doesn't — it uses signals as an implementation detail, but in a way that prevents the sorts of headaches you're describing. Care to elaborate or do you have a link to a blog post explaining further? |
|
Basically, you can only modify state _where it's declared_. If you want to allow the 'outside world' to modify that state, you need to expose a function that does so. This is unlike cases where you're passing around an observable object where anyone with a reference, which they need for reading, can also write to it by doing `thing.value += 1`.
This is something Solid gets right — you can only change a signal's value if you have a reference to its setter.