Hacker News new | ask | show | jobs
by pier25 2219 days ago
I guess we're all different, but I've never had to think much about reactivity in Svelte.

Most of it can be explained in a HN comment:

Component state just does its thing. You change it with = and the component is re-rendered.

Writable stores need to trigger changes with set() and you need to use $ whenever you reference it in a .svelte file so that Svelte handles subscription automatically.

Reactive statements $: are a bit more complex. Every variable inside those is referenced by the compiler so that it knows when you are mutating it. Either with = or if it's a writable store with set().