Input: vuex store
import { logger } from "./logger";
import { ref } from "vue";
export const useSampleStore = defineStore("sample", () => {
const counter = ref(0);
const getCounter = computed(() => {
return counter.value;
});
const increment = () => {
console.log("increment action");
logger.info("increment");
counter.value++;
};
const fetchCounter = async () => {
// make request
const res = { data: 10 };
counter.value = res.data;
return res.data;
};
return { counter, getCounter, increment, fetchCounter };
});