S
SolidJS•3mo ago
anthy

Retrigger fetcher in createResource on store change

https://playground.solidjs.com/anonymous/52b7a9be-3fe1-406a-8941-a3d0a4959bfe As in the example, if the source argument is the whole store the fetcher in createResource wont run. How can I make it re-run if any of the store's values change
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
4 Replies
anthy
anthyOP•3mo ago
For the context I'm simulating query params as an in memory Solid store and want to refetch data on their change. Thats why I'd like to pass the store as the signal. Conveniently it also becomes the fetcher argument
REEEEE
REEEEE•3mo ago
In general you can't listen to all properties of a store change at the top level unless you read all of them in the tracking scope. You can do this https://playground.solidjs.com/anonymous/4679ff85-c4b1-451f-99e0-63243edef787 But it might be better to make use of https://github.com/solidjs-community/solid-primitives/tree/main/packages/deep#trackstore
anthy
anthyOP•3mo ago
JSON.stringify works but that trackstore thing doesnt 😦 () => { ...store } works too lol
REEEEE
REEEEE•3mo ago
That works fine if you don't have any nested properties like {count: 0, other: {property: 'hello'}}. Spreading won't track other.property
Want results from more Discord servers?
Add your server