最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

redux - How to wrap runes in Svelte 5.0 - Stack Overflow

programmeradmin0浏览0评论

I am trying to follow Redux style patterns in my SvelteKit app. I want to the attach logging middleware to my state management.

I understand that store.subscribe has been replaced with $effect rune, however something like:

$effect(() => console.log(myStore))

Would not work since $effect can only be used inside an effect (e.g. during component initialisation).

How can I implement this kind of logging in SvelteKit? Are there any established patterns or mechanisms for achieving this?

I am trying to follow Redux style patterns in my SvelteKit app. I want to the attach logging middleware to my state management.

I understand that store.subscribe has been replaced with $effect rune, however something like:

$effect(() => console.log(myStore))

Would not work since $effect can only be used inside an effect (e.g. during component initialisation).

How can I implement this kind of logging in SvelteKit? Are there any established patterns or mechanisms for achieving this?

Share Improve this question edited Feb 15 at 18:45 Paolo 21.1k21 gold badges76 silver badges121 bronze badges asked Feb 15 at 4:45 Justin LeeJustin Lee 11
Add a comment  | 

1 Answer 1

Reset to default 1

You can create independent effects by wrapping the $effect in an $effect.root.
(These also need to be cleaned up manually.)

发布评论

评论列表(0)

  1. 暂无评论