Skip to content

Commit

Permalink
Add getter function
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Aug 10, 2024
1 parent d464e13 commit 9fb9c68
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
6 changes: 6 additions & 0 deletions app/assets/stores/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineStore } from 'pinia'
import axios from 'axios'
import { getProperty } from 'dot-prop'

export const useConfigStore = defineStore('config', {
persist: true,
Expand All @@ -8,6 +9,11 @@ export const useConfigStore = defineStore('config', {
config: {}
}
},
getters: {
get: (state) => {
return (key: string, value?: any): any => getProperty(state.config, key, value)
}
},
actions: {
async load() {
axios.get('/api/config').then((response) => {
Expand Down
30 changes: 30 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
"dist/"
],
"dependencies": {

"dot-prop": "^9.0.0"
},
"peerDependencies": {
"vue": "^3.4.21",
"axios": "^1.5.0",
"pinia": "^2.1.6",
"pinia-plugin-persistedstate": "^3.2.0"
"pinia-plugin-persistedstate": "^3.2.0",
"vue": "^3.4.21"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.8.0",
Expand Down

0 comments on commit 9fb9c68

Please sign in to comment.