import { defineStore, useStore } from '@vegajs/vortex';
const counterStore = defineStore(({ reactive, computed }) => {
const count = reactive(0);
const doubleCount = computed(() => count.value * 2);
const increment = () => count.set(prev => prev + 1);
return { count, doubleCount, increment };
});
export const A = () => {
const { count, doubleCount, increment } = useStore(counterStore);
return (
<div>
<p>count: {count}</p>
<p>double count: {doubleCount}</p>
<button onClick={increment}>Increment</button>
</div>
);
};