S
SolidJSโ€ข2y ago
oneiro

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 ๐Ÿ™‚ l
5 Replies
thetarnav
thetarnavโ€ข2y ago
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
oneiro
oneiroOPโ€ข2y ago
thanks ๐Ÿ™‚
thetarnav
thetarnavโ€ข2y ago
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
thetarnav
thetarnavโ€ข2y ago
create a new store every time the resource updates This way you have a normal resource and normal store to interact with
oneiro
oneiroOPโ€ข2y ago
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)
Want results from more Discord servers?
Add your server