I'm fairly new to solidjs and maybe I've overlooked something but given the following example I try to understand the issue here:
const [state, setState] = createStore({ items: new Map() }); // e.g. Map<number, string>
In a component let's say I want to use a derived state of the store like so:
export const Overview = () => {
const count = () => state.items.size;
return (<div>{count()</div>);
};
If I now add a new entry to the map I would have expected that the count property would be updated automatically since I use the dependency.
I've tried this example with an array instead of the map and this is working just fine and the component displays the correct and expected value(s).
Can somebody point me maybe to the correct section in the documentation or explain why a Map is not working but an array does?
A signals notify its subscribers when its value change but you are not setting a new value but inserting new item to it hence the action is not perceived as update. You should set a new map and move the inserted values into the new map by cloning the old one.