Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

310
Vistas
Is it possible to somehow change the value of a derived store directly?

I am currently working with SvelteKit.

I have a derived store, which is necessary because it depends on another store. Now I need to change some values in the derived store directly. The problem is that derived stores are not modifyable as far as my understanding goes.

Is there any way to change the value of a derived store directly?

For example if I'd have a derived store called tiles which is an array of objects and I would like to change the property of one of its objects ($tiles[n].x = 'something new')

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can make a derived store writable by simply adding a set function.

You will need either access to the source object from which the value is derived or you need to merge the new value in a way that preserves the relevant object references. (Though in the latter case you may still need to do a dummy reassignment on the parent store, to trigger an update.)

E.g.

const parent = writable({ items: [{ name: 'pochi' }, { name: 'maru' }]});
const items = derived(parent, value => value.items);
items.set = newItems => $parent.items = newItems;

REPL

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda