$inspect detects change in state but $effect() doesn't
#17349
-
|
so, i have a state which is an array of objects.
Demo not sure if it $effect only triggers if the code inside the block actually does some sort of access to that particullar property of the object like mapping over each element of the array, etc. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Effects only run when read signals change. Your demo only reads the top-level signal. In the effect, read the entire tree like this: $state.snapshot(file_tree);If you want to know in more detail how effects work, read my blog article: Svelte Reactivity: Let's Talk About $Effects |
Beta Was this translation helpful? Give feedback.
Effects only run when read signals change. Your demo only reads the top-level signal. In the effect, read the entire tree like this:
If you want to know in more detail how effects work, read my blog article: Svelte Reactivity: Let's Talk About $Effects