I am trying to get my language table’s data from db in store.js and modify that data based on the language user selected. So the selected language is a writable variable and I need to get a derived function that returns the modified data. Here is my code in store.js Here is the code in my +page.svelte I am getting
Tag: svelte-store
Why does a derived Svelte store have different behaviour when using `$` vs `subscribe`
I have a data model that I can’t change in this project. I’m trying to strip down and simplify the sample code below, so hopefully this still makes sense with what I’m trying to re-produce. Let’s say I have two stores. One store holds “containers” and the other store holds “items” – each store is independently used throughout the app
Svelte: Get User Input Callback via Store Function
What I’m trying to do here may not be possible, but as a newcomer to Svelte, I hope it is. 😄 I have a delete button in a component that opens a globally available modal that serves as a confirmation dialog. The modal component is in my __layout.svelte so I can invoke it from anywhere in my app. Here is
How should I efficiently add to an array from a Svelte store subscription?
I’d like to have objects added to an array in a component each time a subscribed store gets updated. In this case, the store is receiving data from a WebSocket, and I ultimately want to plot the last N datapoints that I’ve received (N=1000 for example). The store is defined in socket.js: I then have a Chart.svelte component which should
Iterate over Store via Map
Via a Map Objects are added to a Svelte Store. Every object has an ID and it should be possible to iterate over those IDs. With $entities.get(“123”).currentPage; The current Page of this Object is returned. How can I iterate over more than one ID such that the current pages of all objects in the store are returned? Answer You could
Svelte store function update
Svelte store documentation shows String or Integer being updated, but I did not find any dynamic function in store. I don’t understand how to make the getData function as a writable in order to notify the html of the change. In the following sample, I would like b to be shown after the updateKey function is called. You will find
Making class instance reactive in Svelte using stores
I am learning Svelte by creating simple app. The logic is written using classes. The idea is, that all the data needed comes from class instance properties. Instances should not be instantiated more than once. I am using stores to provide components this instances. The problem is I can’t get reactivity using this approach. I tried readable and writable stores