Skip to content

Instantly share code, notes, and snippets.

@danielkellyio
Last active October 2, 2024 09:38
Show Gist options
  • Save danielkellyio/d82bd6c803e3ec04e498b38cccf63981 to your computer and use it in GitHub Desktop.
Save danielkellyio/d82bd6c803e3ec04e498b38cccf63981 to your computer and use it in GitHub Desktop.
VS Code Snippet for Defining Pinia Stores
{
"Pinia Store Boilerplate": {
"prefix": "pinia",
"body": [
"import { defineStore, acceptHMRUpdate } from \"pinia\";",
"",
"export const use$TM_FILENAME_BASE = defineStore(\"$TM_FILENAME_BASE\", {",
" state: () => {",
" return {",
" $0",
" };",
" },",
" getters: {},",
" actions: {},",
"});",
"",
"if (import.meta.hot) {",
" import.meta.hot.accept(acceptHMRUpdate(use$TM_FILENAME_BASE, import.meta.hot));",
"}",
""
],
"description": "Bootstrap the code needed for a Vue.js Pinia store file"
}
}
@danielkellyio
Copy link
Author

Instructions for Use

  • Run VS Code Command "Preferences: Configure User Snippets"
  • Choose JavaScript from menu
  • Add snippet to javascript.json
  • Repeat process for TypeScript if desired

@vifeng
Copy link

vifeng commented Feb 13, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment