All Questions
57 questions
2
votes
1
answer
119
views
Only fire set if object data has changed in Svelte store
In Svelte, when using a writable store that takes a single primitive value (e.g. a string), when firing set multiple times for the same value, subscribe will only be called when the value changes. ...
0
votes
1
answer
513
views
Svelte 5 reactive store methods
The below code is working as it should, I'm just trying to gain a better understanding of why.
How is the getCurrentElement method of TestState reactive without the use of $derived()? Are store ...
0
votes
0
answers
81
views
How to bind Svelte Store when the value inside object?
I have a custom component InputGroup. It can render checkbox or radio type of input. The selected value is always Svelte Store. But the first store is top of scope, the second inside object. I use $: ...
0
votes
0
answers
446
views
Svelte Component Errors: Cannot read properties of null (reading 'current'), TypeError: unsubscribe is not a function
I have a component that accesses a svelte store writable but the component just gets rendered before the data arrives into the store variable.
This are the errors
enter image description here
I want ...
0
votes
1
answer
254
views
Why are svelte derived stores always recreated on get()?
Now this is more directed towards Svelte authors I suppose, but I just recently fully realized that derived stores are constantly recreated on get.
Example
<script>
import { derived, get, ...
1
vote
1
answer
310
views
Is it possible to have two writable stores in svelte subscribe to each other?
There's an object where its data matches with another object, yet they have different structures.
For example, consider this scenario:
The 'Team' object holds the team ID as its key.
The 'Team' object ...
2
votes
1
answer
3k
views
Creating a writable svelte store from loaded page data in sveltekit
Using sveltekit with svelte 4,
There's data required to server side render pages that is loaded in the root +layout.server.js. The data is then used both on the client and server side, however, I need ...
0
votes
1
answer
507
views
Combine contents of svelte store with store of stores
I am trying to create a derived store which concatenates the values of a store with the values of a store of an array of stores
import {writable, derived} from 'svelte/store';
const a = writable(1);
...
0
votes
2
answers
2k
views
Sveltekit: display alert message after redirecting
I'm working on a project using Sveltekit for the frontend. To display on screen alert messages I had created the following.
In +layout.svelte (the main layout file) I have:
<!-- Main content -->
...
0
votes
1
answer
34
views
How to wrap an existing readable store to add extra parameters?
I am new to Svelte. I'm trying to wrap a small wrapper around svelte-i18n to allow relative translation key.
This is how the library can be used:
<script>
import { _ } from 'svelte-i18n';
</...
1
vote
0
answers
165
views
How to replace component by another component in svelte with undo and redo action?
I want to design front-end system where,
Frame A -> can be replaced with Frame B (user action on frame, leads to transition - e.g. click)
Frame A's transition to Frame B mutates some global state ...
0
votes
1
answer
966
views
Change subscribe element with variable svelte
I have a multiple Svelte stores that looks like this:
import { readable } from "svelte/store";
export const NatureStore = readable([
{
name: "nature",
description:
...
0
votes
1
answer
1k
views
How to create a Svelte derived store that executes code only when new items are added to an array in another store
I'm working on a SvelteKit app in which all functionality is based on a list of URLs. Users can add URLs to this list, or remove them.
When a new URL is added, the app fetches the URL and then runs ...
1
vote
3
answers
6k
views
How to implement a global store in sveltekit?
So, I am building an ecommerce app in sveltekit and wanted to implement cart as a global store, so components can query that store for cart status. I pretty much know how to implement it in a single ...
1
vote
1
answer
490
views
How to return a derived function that use fetched data from db based on value of another writable value in svelte/svelte kit?
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 ...