General Funky Usage #247
Replies: 4 comments 4 replies
-
The $store.subscribe(store => {
store.initialized = true // This line will lead to unexpected behaviour
}) The problem is that changing key in store’s value will change the store, but will not notify the subscribers. We didn’t plan to explicitly ban replacing the variable in Svelte, it is just side effect of this DX fix for pure JS If you know a way to keep protection from mistake and make it easier to write Svelte code, send PR. |
Beta Was this translation helpful? Give feedback.
-
Can you show |
Beta Was this translation helpful? Give feedback.
-
export const teamOneProgressBarColors: WritableAtom<Array<RGB>> = persistentAtom<Array<RGB>>('progressBarColors', [[0, 0, 0], [0, 0, 0]], {
encode: (unencoded: Array<RGB>) => JSON.stringify(unencoded),
decode: (encoded: string) => JSON.parse(encoded),
}); persistent map (as these will be browser sourced in OBS and I want to use local caching to not reset the scene) -- the other thing i wanted to say was Vue has the same issue with maps, but the thing is you can't protect people from themselves. I can simply just do |
Beta Was this translation helpful? Give feedback.
-
Honestly, it's hard for me to understand what you want to do and how you expect the code to work. |
Beta Was this translation helpful? Give feedback.
-
Hey there,
so I have a few issues with the way persistent works
First of all, if I make a Map or Array persistent, it becomes readonly, in Svelte, in Astro, wherever, the persistent modules become readonly if they are an array or object. An example
this is the configuration for my Threlte (Svelte ThreeJS) scene, I store it this way because my brother is going to OBS capture it, so between different loads I want the data to stay the same. Now the issue is, when I use it, it becomes readonly
so that's one issue, I don't know why it's readonly
The second issue is as someone else previously mentioned, and a more general Nanostores issue
what the heck is the point of using encode and decode values if I still have to decode the stringified local value? That's confusing and I don't understand what's going on there.
Beta Was this translation helpful? Give feedback.
All reactions