$inspect detects change in state but $effect() doesn't #17349
Answered by webJose
Keshav-writes-code asked this question in Q&A
-
| 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.
Answered by webJose Dec 11, 2025
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.
1 reply
Answer selected by Keshav-writes-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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