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