How to set up a pinia store to wait for the state #1996
Unanswered
entioentio
asked this question in
Help and Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a (composition) store that is used in s couple of modules, they are unaware of each other and can be initialized in the same moment as well as at different times.
The store retrieves data from an API and saves it in the state. All of the modules execute the store's
fetchData
method, all of them await a promise it returns.The problem is that when the modules are initialized at the same moment, both perform
fetchData
resulting in two requests fired. The ideal situation would be toThose with a requirement that the modules are unaware of the store implementation - the less code on their side the better.
How do you handle such cases?
Is a there anything wrong with this approach? If not - how to implement it?
Beta Was this translation helpful? Give feedback.
All reactions