1
1
{
2
- "Pinia Store" : {
3
- "prefix" : " pstore" ,
4
- "body" : [
5
- " import { defineStore } from 'pinia'" ,
6
- " " ,
7
- " export const useCounterStore = defineStore('counter', {" ,
8
- " \t state: () => {" ,
9
- " \t\t return { count: 0 }" ,
10
- " \t }," ,
11
- " \t actions: {" ,
12
- " \t\t increment() {" ,
13
- " \t\t\t this.count++" ,
14
- " \t\t }," ,
15
- " \t }," ,
16
- " })"
17
- ],
18
- "description" : " Basic Pinia Store"
19
- }
2
+ "Pinia Store" : {
3
+ "prefix" : " pstore" ,
4
+ "body" : [
5
+ " import { defineStore } from 'pinia'" ,
6
+ " " ,
7
+ " export const useCounterStore = defineStore('counter', {" ,
8
+ " \t state: () => {" ,
9
+ " \t\t return { count: 0 }" ,
10
+ " \t }," ,
11
+ " \t actions: {" ,
12
+ " \t\t increment() {" ,
13
+ " \t\t\t this.count++" ,
14
+ " \t\t }," ,
15
+ " \t }," ,
16
+ " })"
17
+ ],
18
+ "description" : " Basic Pinia Store"
19
+ },
20
+ "Pinia Store State Refs" : {
21
+ "prefix" : " pstorestaterefs" ,
22
+ "body" : [
23
+ " import { useCounterStore } from '@/store/main'" ,
24
+ " " ,
25
+ " const store = useCounterStore()" ,
26
+ " const { count } = storeToRefs(store)" ,
27
+ " // You can access destructured state like so: store.counter++"
28
+ ],
29
+ "description" : " Destructure Pinia State"
30
+ },
31
+ "Pinia Store Patch" : {
32
+ "prefix" : " pstorepatch" ,
33
+ "body" : [
34
+ " store.$patch({" ,
35
+ " \t count: store.count++" ,
36
+ " })"
37
+ ],
38
+ "description" : " Pinia Store Patch"
39
+ },
40
+ "Pinia Store Patch Function" : {
41
+ "prefix" : " pstorepatchfunction" ,
42
+ "body" : [
43
+ " store.$patch((state) => {" ,
44
+ " \t state.items.push({ name: 'shoes', quantity: 1 })" ,
45
+ " \t state.hasChanged = true" ,
46
+ " })"
47
+ ],
48
+ "description" : " Pinia Store Patch Function"
49
+ }
20
50
}
0 commit comments