Closed ewal closed 1 year ago
Calling the function returns a writable store that you can pass to the derived. What kind of calculations you need to do?
I have tried calling the queryParameters function in the derived store but I get the following error:
Error: Cannot subscribe to 'page' store on the server outside of a Svelte component, as it is bound to the current request via component context. This prevents state from leaking between users.For more information, see https://kit.svelte.dev/docs/state-management#avoid-shared-state-on-the-server
(I basically want to filter a store based on the values in the query params).
I found a solution by subscribing to the queryParameters()
store from where I update another store that can used in the derived store. Bit of a overhead perhaps but works fine :+1:
Than its a different problem: you are trying to subscribe to the store in the load function but this is a security issue.
You should just use this store inside a svelte component
Strange, because I got the error when I tried to use the queryParameters store inside a derived store :thinking: (Not subscribing to it, that is). Anyway, I kinda realized I have all I need inside the $page object so I will close this issue now... Thank you for your replies.
Describe the problem
I would like to do some computations in a derived store based on values returned from
queryParameters
but can't figure out how. I guess that it may currently not be possible based on howqueryParameters
is exported? Currently it's exported as a function but the derived store expects awritable store
as an argument.Describe the proposed solution
It would be great to have an exported
writable store
that could be used as such: