UNPKG

svelte-ux

Version:

- Increment version in `package.json` and commit as `Version bump to x.y.z` - `npm run publish`

19 lines (18 loc) 493 B
import { writable } from 'svelte/store'; function dirtyStore(store) { const count = writable(-1); const unsubStore = store.subscribe(() => count.update((x) => ++x)); return { subscribe(run) { const unsubCount = count.subscribe(($count) => run($count > 0)); return () => { unsubStore(); unsubCount(); }; }, reset() { count.set(0); }, }; } export default dirtyStore;