You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/component-slot-fallback-2/store.svelte

23 lines
423 B

<script context="module">
let value = 'Blub';
let count = 0;
const subscribers = new Set();
export const model = {
subscribe(fn) {
subscribers.add(fn);
count ++;
fn(value);
return () => {
count--;
subscribers.delete(fn);
};
},
set(v) {
value = v;
subscribers.forEach(fn => fn(v));
},
getCount() {
return count;
}
};
</script>