ankurrsinghal / svelte-legos

A framework for Svelte Utilities 💡 Current status: 87 utilities.
https://svelte-legos.surge.sh
MIT License
778 stars 27 forks source link

`cssVarStore` is not a Writable #117

Closed julien-blanchon closed 4 months ago

julien-blanchon commented 4 months ago

I would like to use cssVarStore store with storage one but cssVarStore don't return update so it's not a Writable and storage is complaining about it

julien-blanchon commented 4 months ago

Property 'update' is missing in type '{ subscribe: (this: void, run: Subscriber<string>, invalidate?: Invalidator<string> | undefined) => Unsubscriber; set: (value: string) => void; }' but required in type 'Writable<string>

julien-blanchon commented 4 months ago

https://github.com/ankurrsinghal/svelte-legos/pull/118

julien-blanchon commented 4 months ago

Currently this is my only workaround:

import { cssVarStore } from 'svelte-legos';
import { storage } from 'svelte-legos';

let bg_css = cssVarStore('--bg');
let bg = storage({ ...bg_css, update: (updater) => bg_css.set(updater($bg_css)) }, 'bg');
ankurrsinghal commented 4 months ago

Thanks @julien-blanchon for the heads up. Merged the PR.