You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So when you use a store, it wraps it in a reactive, which is helpful since you don't have to use .value and it means composition and options stores are the same. But it's also really annoying because it's not what you expect it to be if you're returning refs and you can't destructure them. It's quite annoying to have to use storeToRefs or computed when it's not really necessary.
Proposed solution
Solution 1: Allow passing an options object when you create the store, including the two current options, plus an option to not unwrap refs. This would be harder because wrapping it is done when you define it, at least that's what it looks like when I look at the source code.
Solution 2: Make this an option when you define the store instead of when you create it. This is easier, but it's probably not as good since it isn't obvious when you use it, you'd have to look at the definition or maybe the types.
Describe alternatives you've considered
No response
The text was updated successfully, but these errors were encountered:
For now, there is no intention of shipping this feature with the existing ones because it makes things different when using the store, while it is not explicit why things are not unwrapped anymore (still same useStore() call). In practice, I've played with both ideas, and I rarely extract refs from the store, I use the store directly, as a whole, as a service. You don't need to use storeToRefs().
It's also worth noting that this can be implemented in user land with a custom defineStore that calls storeToRefs().
That being said, I don't want to give up the idea yet completely, so I will move it to Discussions and see if the community comes up with other arguments
What problem is this solving
So when you use a store, it wraps it in a reactive, which is helpful since you don't have to use
.value
and it means composition and options stores are the same. But it's also really annoying because it's not what you expect it to be if you're returning refs and you can't destructure them. It's quite annoying to have to use storeToRefs or computed when it's not really necessary.Proposed solution
Solution 1: Allow passing an options object when you create the store, including the two current options, plus an option to not unwrap refs. This would be harder because wrapping it is done when you define it, at least that's what it looks like when I look at the source code.
Solution 2: Make this an option when you define the store instead of when you create it. This is easier, but it's probably not as good since it isn't obvious when you use it, you'd have to look at the definition or maybe the types.
Describe alternatives you've considered
No response
The text was updated successfully, but these errors were encountered: