setting getter in store on already defined key loses reactivity

const [store, setStore] = createStore({ value: 0, alreadyDefinedKey: {}});

setStore('newKey', {
get get() {
return store.value
}
})

setStore('alreadyDefinedKey', {
get get() {
return store.value
}
})
const [store, setStore] = createStore({ value: 0, alreadyDefinedKey: {}});

setStore('newKey', {
get get() {
return store.value
}
})

setStore('alreadyDefinedKey', {
get get() {
return store.value
}
})
in the above example store.alreadyDefinedKey.get will not update its value when store.value gets updated. is this expected behavior? can we only set getters when initializing its parent? https://playground.solidjs.com/anonymous/972b3aec-d7df-4ec0-9a68-c8b8b60785e3
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
2 Replies
thetarnav
thetarnav2y ago
top-most objects get merged, so this works
setStore({
alreadyDefinedKey: {
get get() {
return store.value;
},
},
});
setStore({
alreadyDefinedKey: {
get get() {
return store.value;
},
},
});
but maybe this could be improved in core to handle getters better
bigmistqke
bigmistqkeOP2y ago
nice fix, but ye feels a bit wonky! I will add it as an issue on github
Want results from more Discord servers?
Add your server