createResource as initial value with store
Hi,
is there a way to combine the behaviour of
createResource
and createStore
? What I essentially want to achieve, is to fetch a resource and populate a store with the data. But since doing something like this with createEffect
I was wondering, what the best way to do this would be?
Essentially the flow should be:
Fetch data from a local save file -> use this as (almost) initial value for a store -> interact with the store (e.g. change values) and later write it back.
A createMemo
wouldn't really make sense in that case, as there isn't really any form of derived state.
Any tips on what the best idiomatic way to achieve this in solid would be?
Thanks in advance ๐ l5 Replies
GitHub
solid-primitives/packages/resource at main ยท solidjs-community/soli...
A library of high-quality primitives that extend SolidJS reactivity. - solid-primitives/packages/resource at main ยท solidjs-community/solid-primitives
thanks ๐
You could also do something like this:
https://playground.solidjs.com/anonymous/10c44938-2582-4afa-98cd-332a386c9212
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
create a new store every time the resource updates
This way you have a normal resource and normal store to interact with
ah interesting, didn't know about the
keyed
prop. Thanks again!
@thetarnav I still can't really figure this one out. I posted another question related to this one here: https://discord.com/channels/722131463138705510/1117416890260783155/1117416890260783155
Would you mind taking a look at it? (I provided some code over there and believe that it better highlights my actual issue)