How to create multiple same stores without duplicating its code? #771
-
I need to create three the same stores but with different names like this:
and I want to extract options to one single place to avoid code duplication. What is the proper way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
create one object and copy it, just like regular js: const options = {}
defineStore('one', {...options})
defineStore('two', {...options}) |
Beta Was this translation helpful? Give feedback.
-
I also posted the full solution on stackoverflow.com: It comes down to this:
And then in the component:
If you do want to share the same store somewhere, you just use the same id's, otherwise a unique id |
Beta Was this translation helpful? Give feedback.
-
Hello @Jalliuz . Could you explain the purpose of |
Beta Was this translation helpful? Give feedback.
create one object and copy it, just like regular js: