Closed Not-Jayden closed 3 months ago
Latest commit: 0d57b4c6d868074123982620922849bcfb224a0d
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Name | Status | Preview | Last Commit |
---|---|---|---|
runed | ✅ Ready (View Log) | Visit Preview | 0d57b4c6d868074123982620922849bcfb224a0d |
This is not a bug. This is how Svelte's effects work. They don't trigger on object mutations. You can get around this by using $state.snapshot
, which deeply copies the object.
watch(() => $state.snapshot(condition)
I don't think we should use $state.snapshot internally. It should be opt-in.
I don't think we should use $state.snapshot internally. It should be opt-in.
Yeah I'm in agreeance with you on this one. Defeats the purpose of "deeply reactive" by default and would create unexpected outcomes (when compared with using, say, a regular $effect
).
We should document this behavior just for future reference, but gonna close this one as it should be handled in user land on an opt-in basis. Thanks @Not-Jayden!
Ensure
watch()
runs when object properties are mutatedCloses #119