Allow define store options in setup stores #2811
-
What problem is this solvingCurrently, the option stores are able to add extra options when defining a store, for example: export const useCounterStore = defineStore('counter', {
+ persist: true,
state: () => ({ count: 0, name: 'Eduardo' }),
getters: {
doubleCount: (state) => state.count * 2,
},
actions: {
increment() {
this.count++
},
},
}) But there is no way to define the options when using the setup store. Proposed solutionImplement a new function allowing to define the store options when using the setup store, just like vue defineOptions macro export const useCounterStore = defineStore('counter', () => {
+ defineStoreOptions({ persist: true })
const count = ref(0)
const name = ref('Eduardo')
const doubleCount = computed(() => count.value * 2)
function increment() {
count.value++
}
return { count, name, doubleCount, increment }
}) Describe alternatives you've consideredNo response |
Beta Was this translation helpful? Give feedback.
Answered by
posva
Oct 30, 2024
Replies: 1 comment
-
It's already possible with the second argument: defineStore('id', () => {}, options) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
sontd-nals
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's already possible with the second argument: