You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could the Svelte compiler have syntax to reactively destructure stores that are nested as a property of another object? This example shows how $store can only be reactively destructured as a top-level object, requiring an intermediate top-level variable to be declared for the store:
<script>
import { readable } from'svelte/store'conststore=readable({ val:111 })constobj= { store } $: ({ val } = $store) // ✅ val is updated reactively $: ({ val } =obj.$store) // ❌ $store is a literal property (undefined) $: ({ val } = obj.($store)) // ❌ invalid JS
</script>
val: {val}
Syntax obj.$store or obj.($store) could reactively access nested stores. This could make imports, code architecture, and store value deconstruction more flexible:
Duplicate of #4079. But, realistically, I don't know that this will get much attention now with the new reactivity models being introduced in Svelte 5.
Describe the problem
Could the Svelte compiler have syntax to reactively destructure stores that are nested as a property of another object? This example shows how $store can only be reactively destructured as a top-level object, requiring an intermediate top-level variable to be declared for the store:
https://svelte.dev/repl/1df711beb6cb46dda8b8283a3be0bbf2?version=4.2.12
Describe the proposed solution
Syntax
obj.$store
orobj.($store)
could reactively access nested stores. This could make imports, code architecture, and store value deconstruction more flexible:Importance
would make my life easier
The text was updated successfully, but these errors were encountered: