N
Nuxtβ€’2mo ago
ZaKk

delete pinia store data.

hey guys, is there any way to delete one of the pinia stores programatically? for example i want to delete "menu" and "layout" every time a user logs out. using nuxt 3.0.0, vue 3.2.13 and pinia 2.0.34
No description
29 Replies
kogratte
kogratteβ€’2mo ago
kogratte
kogratteβ€’2mo ago
?
ZaKk
ZaKkOPβ€’2mo ago
i really can't figure out how to use that :S
kogratte
kogratteβ€’2mo ago
UseMyStore().$dispose()
ZaKk
ZaKkOPβ€’2mo ago
No description
ZaKk
ZaKkOPβ€’2mo ago
No description
ZaKk
ZaKkOPβ€’2mo ago
No description
kogratte
kogratteβ€’2mo ago
I can help you but it won't really help. What about reading the manual as well as js fundamentals re. Scopes? Tips:you cannot dispose something that doesn't exists. And you can't destroy the store from itself, rather from where it is used.
ZaKk
ZaKkOPβ€’2mo ago
hmmm i know i cannot destroy an object from itself, i want to destroy another store from this scope but it seems i can't see the other store from here
kogratte
kogratteβ€’2mo ago
Two questions. Why are you stucked with js? Why don't use typescript as well as the new store syntax which is well documented by pinia's team? I bet you'll get better visibility and readability. Re. Your question, it should works as long as you're not disposing this store from the logout. I'm using something similar on a projet and it works well. May it be due to the async modifier?
ZaKk
ZaKkOPβ€’2mo ago
i'm stuck in some parts with JS because the template was built like that, all my code is TS tho.
kogratte
kogratteβ€’2mo ago
BTW, defineStore will create a new store, not use an existing one. Could you use an exported ref?
ZaKk
ZaKkOPβ€’2mo ago
disepose is not deleting the data, when i log out the data is still there
kogratte
kogratteβ€’2mo ago
:/
ZaKk
ZaKkOPβ€’2mo ago
tried with reset() too and it seems to be the same
ZaKk
ZaKkOPβ€’2mo ago
No description
ZaKk
ZaKkOPβ€’2mo ago
it doesn't seem to delete the data
kogratte
kogratteβ€’2mo ago
As you're using option store, does $reset do the trick?
No description
ZaKk
ZaKkOPβ€’2mo ago
reset works but i have to log out twice for it to work, kind of weird...
kogratte
kogratteβ€’2mo ago
Sounds like a ref issue or something like that...
ZaKk
ZaKkOPβ€’2mo ago
might be, will have a more deep look into that and the code flow
kogratte
kogratteβ€’2mo ago
The ideal would be to understand why this double logout is needed... Can't do that ^^
ZaKk
ZaKkOPβ€’2mo ago
yeah i know mate
kogratte
kogratteβ€’2mo ago
Was harsh. Sorry about that. Was missing some ctx.
ZaKk
ZaKkOPβ€’2mo ago
no problem mate πŸ˜‰
kogratte
kogratteβ€’2mo ago
Hey Zak! Did you find a way?
ZaKk
ZaKkOPβ€’2mo ago
nope, i think i should rewrite the component that loads the menu and load it dynamically from database
kogratte
kogratteβ€’2mo ago
May it be due to a remaining ref to the store you're trying to delete?
ZaKk
ZaKkOPβ€’2mo ago
might be but i wanted to rewrite it anyway xd
Want results from more Discord servers?
Add your server