Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Adding a readable store to writable store

$
0
0

I'm trying to add a readable store as a default value to a writable store, so that the user will see some default value when he opens the app.

I have one large readable store - taskStore, which contains different objects with task information, as follows:

import { writable, readable } from "svelte/store";// The video directories together with the corresponding frame counts should be placed hereexport const taskStore = readable(    [         {            imageDir: '100159',            frameCount: 50,            labels: [                { frame: 10, x: 125, y: 60 },                { frame: 10, x: 125, y: 60 },                { frame: 10, x: 125, y: 60 },            ]        },        {            imageDir: '100589',             frameCount: 50,             labels: []        }    ])

So I tried adding the first value of the taskStore to the writable currentTaskStore, like this:

export const currentTaskStore = writable([taskStore[0]])

but it doesn't work, and I get the undefined value when I try to use this store in other components. Is it possible to use a writable store with complicated objects, or are they for primitives only?


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>