updating a member inside another member inside an array inside a store using an index
o/ so i have data structured as follows, which is inside a store:
when i do this:
modifying works fine. but i have an effect subscribed to it
this doesn't get re-triggered when the
data
changes. any idea?5 Replies
i tried using
and
but it still doesn't get triggered
might be useful: instead of modifying an existing element in the array i added items instead using [...prevList, newValue], and that seemed to trigger the effect just fine
also tried using a mutable store with createMutable, but modifying an element still didn't seem to work
update: for some reason doing this:
instead of
worked. (block and action are the same type)
now, why did that work but setting
data
only didn't?Fine-grained means that there's no change to actions. You can still track deep changes using our community package @solid-primitives/deep. Another valid option would be to wrap the setter to detect changes.
ah i see. so it can't detect things deeper than, say, 2 levels?
i thought stores by default react to everything inside them
it can but you aren't listening for the part that actually changed which is some
block
data inside of actions
Meaning that when you change some block
data inside of actions
, anything that was listing to actions[0].block.data
will react to changes but not anything that was listening to actions
Oooh I see now