-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve documents and examples for composition api store #2065
Comments
I think it does? Following page have the exact example on how to use it in setup function. And this applies same to js/ts file. What made you confusing? |
By examples I mean the examples in this link ( quote from the docs ) |
@tuan-lm97 Every example has at least one usage of
|
@cuebit @kiaking I know it really silly, but before write this issue, I have wasted 30m figure it out why is
Now I know that the problems is because I don't call myFunc inside my setup function, instead I just return to use it in my template. I know this is mostly because I don't understand how the composition work but it would be nice if there are some examples for beginner don't make silly mistake like this |
In that case I think it would make more sense to add that special note to the Docs's composition api page. That says "You must always call I'm not sure if we should force our example to use external ts/js file. Because it will make the code harder to read in my opinion. Examples should be as simple as possible. And it might give users impression that "you must separate file", or "separating file is a good practice". Which is not always true. Also, even if we had that example, I think it's evenly hard to understand that the external function must be called inside So following up the issue in the docs sounds like a good idea to me. |
I would also add that at least one typescript example would be nice. I often have trouble getting the typing on the getters correct. |
Yes, I also think example should have more variant, especially typescript related stuff. Vue 3 natively support typescript but on the document side, it haven't got enough love |
How about an example of using mapGetters within the setup function? |
So what would be the proper way to do this? How should we handle using the store in files that aren't components? |
What problem does this feature solve?
Currently, the document describe how to use composition api of vuex useStore is very limited.
None of the example show how to use useStore in .vue flies setup function and in js/ts files.
What does the proposed API look like?
To the very least, the examples must include useStore() examples, how to import and use them in .vue setup function and in .js/ts files
The text was updated successfully, but these errors were encountered: