Skip to content
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

storeToRefs() by default #2082

Closed
nerdcave opened this issue Mar 19, 2023 · 4 comments
Closed

storeToRefs() by default #2082

nerdcave opened this issue Mar 19, 2023 · 4 comments

Comments

@nerdcave
Copy link

nerdcave commented Mar 19, 2023

What problem is this solving

I use storeToRefs far more often than not, and it would be nice if there was a way to make it the default behavior.

For example, I want to simplify the store usage from this:

const { posts, loading, error } = storeToRefs(usePostStore())
const { fetchPosts } = usePostStore()

To this:

// no storeToRefs call, get actions too
const { posts, loading, error, fetchPosts } = usePostStore()

Proposed solution

const usePostStore = defineStore("post", () => {}, { asRefs: true })

Some option when defining the store that will eliminate the need to call storeToRefs.

Describe alternatives you've considered

Global pinia config option?

@avinean
Copy link

avinean commented Mar 28, 2023

Don't use storeToRefs

Copy link
Member

posva commented Apr 3, 2023

Duplicate of #718

Copy link
Member

posva commented Apr 3, 2023

You can use #718 (comment).

@posva
Copy link
Member

posva commented Apr 3, 2023

Please, search existing issues and pull requests before opening issues, it saves maintainers a lot of time 🙏

@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants