Skip to content

Commit d21ea1d

Browse files
committed
feat: Add Pinia composition store snippets (#29)
* Pinia composition API snippet #26 * Documentation #26
1 parent 52cb591 commit d21ea1d

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

Diff for: README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,12 @@ These snippets were made to speed up Vue 3 development. With it you can write bo
8181

8282
### Pinia
8383

84-
| Snippet | Purpose |
85-
| -------- | --------------------------------------- |
86-
| `pstore` | Base code needed for a Pinia store file |
84+
| Snippet | Purpose |
85+
| ---------------------- | ------------------------------------------------------------ |
86+
| `pstore` | Base code needed for a Pinia store file |
87+
| ⚠️ `pstore-composition` | Base code needed for a Pinia store file with Composition API |
88+
89+
> Snippets with ⚠️ symbol are unreleased.
8790
8891
### Vue Router
8992

Diff for: snippets/pinia.code-snippets

+16
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,21 @@
1818
""
1919
],
2020
"description": "Base code needed for a Pinia store file"
21+
},
22+
"Pinia Store Base - Composition API": {
23+
"prefix": "pstore-composition",
24+
"body": [
25+
"import { defineStore, acceptHMRUpdate } from \"pinia\"",
26+
"",
27+
"export const use${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Store = defineStore(\"$TM_FILENAME_BASE\", () => {",
28+
"\t${0}",
29+
"})",
30+
"",
31+
"if (import.meta.hot) {",
32+
"\timport.meta.hot.accept(acceptHMRUpdate(use${TM_FILENAME_BASE/(.*)/${1:/capitalize}/}Store, import.meta.hot))",
33+
"}",
34+
""
35+
],
36+
"description": "Base code needed for a Pinia store file with Composition API"
2137
}
2238
}

0 commit comments

Comments
 (0)