Load Pinia Setup Actions from external lib #2553
-
Hello, I'm trying to load the setup of a pinia store from an external module (loaded through importmaps ) for reusability
When I load the setup and pass it directly to the store definition, I arrive to execute the action and mutate the state but the UI remains in the same state. Should I load the pure function after the pinia instance creation? Any suggestions? Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Is this the same issue as #2551 ? |
Beta Was this translation helpful? Give feedback.
-
Hello, in the end I was able to load the setup actions through importmaps. In my case, I am working with a structure of microfrontends so each mfe should implement the same definition to get aligned. Let's say I want to share the implementation of a Notification Service (common to all microfrontends): 1. From my lib I will export the actions setup as:
Then, I will also have to share the presentational component:
Both the setup actions and the presentational component will be exported from my lib and loaded in each microfrontend as importmaps from a SystemJS register. 2. Load exposed service and component in a microfrontend: First, we need to import the setup actions when defining the store:
Second, we need to register the exposed component in my app. As said, this is loaded through importmaps too:
Third, we can declare the component directly at root level in the
As you can see, the component is registered in the main so no need to import it. To conclude:
Open to improvements and suggestions! Thank you, |
Beta Was this translation helpful? Give feedback.
Hello, in the end I was able to load the setup actions through importmaps. In my case, I am working with a structure of microfrontends so each mfe should implement the same definition to get aligned.
Let's say I want to share the implementation of a Notification Service (common to all microfrontends):
1. From my lib I will export the actions setup as: