3 ms·
> I iteratively move $state() runes out of .svelte files and into .svelte.ts files where I build a more abstract data-oriented structure for my app from a serie
by ansc 2y ago
> I iteratively move $state() runes out of .svelte files and into .svelte.ts files where I build a more abstract data-oriented structure for my app from a series of mutually linked classes. Then those runes can be re-imported into the .svelte files, or used and updated wherever you need.
I don’t know exactly how you do this, but it sounds like you are dangling on the global state of the runes. This is DANGEROUS in Svelte and can definitely ruin your day.
- DecoySalamander 2y agoCould you elaborate on why it's dangerous? Aren't runes just proxies with some variables in them?
- ansc 2y agoOf course! I was very used to SPA, and the convenience of moving a rune/store to an external file meant it could be accessed anywhere (as the post said). With SSR however, if you’re not careful, you can easily leak data: https://github.com/sveltejs/kit/discussions/4339 https://github.com/sveltejs/kit/discussions/4339.
- rofrol 2y agoThanks. also this https://github.com/sveltejs/kit/discussions/4339#discussioncomment-8046758 https://github.com/sveltejs/kit/discussions/4339#discussionc...