<script>
import { writable } from 'svelte/store';
// Make a store
const count = writable(0);
// Subscribe to it, and update the displayed value
let visibleCount = 0;
count.subscribe(value => {
visibleCount = value;
});
// A function to increment the count
function increment() {
count.update(n => n + 1);
}
</script>
<button on:click={increment}>Increment</button>
<p>Current value: {visibleCount}</p>