-
-
Notifications
You must be signed in to change notification settings - Fork 188
/
Copy pathpinia.json
57 lines (57 loc) · 1.37 KB
/
pinia.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{
"Pinia Store": {
"prefix": "pstore",
"body": [
"import { defineStore } from 'pinia'",
"",
"export const useCounterStore = defineStore('counter', {",
"\tstate: () => {",
"\t\treturn { count: 0 }",
"\t},",
"\tactions: {",
"\t\tincrement() {",
"\t\t\tthis.count++",
"\t\t},",
"\t},",
"})"
],
"description": "Basic Pinia Store"
},
"Pinia Store State Refs": {
"prefix": "pstateref",
"body": [
"import { useCounterStore } from '@/store/main'",
"",
"const store = useCounterStore()",
"const { count } = storeToRefs(store)",
"// You can access destructured state like so: store.counter++"
],
"description": "Destructure Pinia State"
},
"Pinia Store Patch": {
"prefix": "ppatch",
"body": [
"store.$patch({",
"\tcount: store.count++",
"})"
],
"description": "Pinia Store Patch"
},
"Pinia Store Patch Function": {
"prefix": "ppatchf",
"body": [
"store.$patch((state) => {",
"\tstate.items.push({ name: 'shoes', quantity: 1 })",
"\tstate.hasChanged = true",
"})"
],
"description": "Pinia Store Patch Function"
},
"Pinia Import Store": {
"prefix": "pstore-import",
"body": [
"import { useCounterStore } from '@/store/main'"
],
"description": "Import a Pinia store"
}
}