Open fnimick opened 5 hours ago
$effect(() => {
let unsub = s.subscribe((obj) => {
if (obj.foo === 'baz') {
obj.bar = 'some';
} else {
obj.bar = null;
}
});
return () => {
unsub();
};
});
Is there a better way to do this?
Describe the bug
When using a store for reactivity, where the store contains an object, svelte 4 allows a reactive block to set a store member based on the value of another store member, without triggering reactivity on the whole store.
In svelte 5, this appears to no longer be possible - assignments to
$store.foo
trigger reactivity on$store.bar
.Example: the svelte 4 version runs once, the svelte 5 version triggers an infinite loop, when the button is clicked.
I'm not sure how to work around this when dealing with libraries that use stores - I am not in control here, and need to update the value of one store member when another store member changes.
Reproduction
https://svelte.dev/playground/hello-world?version=5.2.0#H4sIAAAAAAAAE32QT0-EMBDFv8qkIQESQu8IGG_Ggx48Wg_8mZrG0pJ21nUl_e6mC6jRjadp5v2m780szHQTsordotYWjtbpETIcFeGYs4JJpdGz6mlhdJojFxus2Kdu5rn0b6gp9vrO46X-YA2hIc8qVvvBqZlaYQSpabaOYIGjU9T1GiGAdHaCdJ3knqzD9CqyGgk8NF9otkhrK0iltWkBfecqMAetQx5pIyipYIlVkJKQJb6U1kLTNJD23Uea76KgxJd956CB1NtpMxMUALXHC1Q02ZlYwmrHOSQoJQ6UZTk07TrJOfzrf9YvRzhLP1P8Zr-CrOT2CrkwNf--sanndrl7fLgvPTllXpQ8ZYnPQ83nVpi6PxBZA9YMWg2vzbJl3-P-DQ7X68mh2hYJoZ3sqOSp5utnLSsY4TuxitwBw3P4BNax-WxhAgAA
Logs
No response
System Info
Severity
blocking an upgrade