Replies: 1 comment
-
I'm also discovering these paradigms as I update from Svelte 4 to 5 and search the new docs. It's helpful to have them in one place, thanks. For number 2, I think it works the opposite way though, is that correct? E.g. an update to a store inside a $derived rune triggers an update? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
They might mentioned/documented here and there, I thought it's good to have them in one place. Please correct me if I am wrong and/or let us know if you know about other useful details!
$derived
: Instead of exporting$derived
or$derived.by
just export a function, e.g.() => someRunteState
, less verbose/boilerplate-y; do not forget to call the export when using, contrary to$derived
Runesderived
store (so the one without $), Runes within do not trigger updates; so oldderived
stores need to to be migrated as well.ts
files to.svelte.ts
when you use Runes, you do not need to do so when importing a function which contains Runes, e.g.,count
(a$state
Rune) orderivedCount
(a function, not a$derived
Rune) fromcount.svelte.js
can be imported toanotherFile.ts
and used there; so you need to rename only when Runes are used explicitelyobject
Runes: You can't reassign$state
once exported if it contains primitives, you can work-around by using anobject
; defaulting to objects might seem over-eager and verbose, on the other side, one decision less every time you use them and you can add actions right away; I am not yet decided if it is good to use also a default property key, e.g..value
Beta Was this translation helpful? Give feedback.
All reactions