Using Pinia as a local state manager for a page with complex, multi-layered components #2266
-
I am working with a team creating an SPA using VueJS, with Pinia as our global state manager. We've had multiple issues using VueJS with complex, multi-layered components - specifically, in places containing lists of complex forms with different rules governing how a selection in one place affects the options in another. The issues with VueJS:
Pinia resolves all of the above by default. The only issue with Pinia is that, as a global store, it seems somewhat out of scope. Assuming we clear the data from the store when leaving the page (so no we don't hold large amounts of unneeded data in the background), and that the stores are actually only initialized when needed, is there a reason to not use Pinia in this way? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
It does 👀 , check the
It can: a composable is called within a Vue Component (some other very specific places also work for global provide I also suspect you don't need pinia (or state management for this). The new |
Beta Was this translation helpful? Give feedback.
It does 👀 , check the
InjectionKey
type.It can: a composable is called within a Vue Component (some other very specific places also work for global provide
app.provide()
only, like stores and navigation guards), therefore the composable creates everything within the context of the Vue Component itself.I also suspect you don't need pinia (or state management for this). The new
defineModel()
for custom input elements should help with the boilerplate within custom input components.When it comes to Form …