init pinia

This commit is contained in:
Antony Budianto
2025-01-03 17:37:54 +07:00
parent b0221e1d21
commit de425bd9e5
15 changed files with 241 additions and 34 deletions
+24
View File
@@ -0,0 +1,24 @@
import { defineStore } from "pinia"
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
export const useCounter = defineStore("counter", {
state: () => ({
count: 999
}),
actions: {
increment() {
this.count += 1
},
async asyncIncrement() {
console.log("asyncIncrement called")
await sleep(300)
this.count++
return true
}
},
getters: {
getCount: (state) => state.count
}
})