-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate Vuex store to Pinia #1265
Conversation
458bf90
to
84a24e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM just a couple suggestions
Co-authored-by: Jacob Nesbitt <jjnesbitt2@gmail.com>
🚀 PR was released in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very cool. Thanks @mvandenburgh!
async initializeDandisets({ identifier, version }: Record<string, string>) { | ||
this.uninitializeDandisets(); | ||
|
||
// this can be done concurrently, don't await |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I believe it's just there to clarify why there's no await
in front of the following method so someone doesn't see it and think it's a bug. It was there in the old vuex code, I just copied it over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The confusion I had was between what you just said (explaining why the first statement has no await
) and suggesting that someone should remove the following two await
s and make all three operations concurrent.
schema: null, | ||
}), | ||
getters: { | ||
version: (state) => (state.dandiset ? state.dandiset.version : draftVersion), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we apply TS types to these functions? It would make the list of getters that much more legible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike Vuex with direct-vuex
, Pinia is fully typed, so the types of every function parameter/return value here are inferred automatically without needing to manually specify them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, maybe I'm misunderstanding what you're saying. Are you just asking for explicit types to be added? Like
version: (state) => (state.dandiset ? state.dandiset.version : draftVersion), | |
version: (state): string => (state.dandiset ? state.dandiset.version : draftVersion), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I meant the latter. It's not necessary to fill them all in now, but I think one of the major benefits of TypeScript is that the types are checked by the machine, but also legible to the human.
Closes #1261
For reference, I mostly followed this guide.
One thing to note is that Pinia has a slightly different paradigm than Vuex when it comes to "stores" and "modules". Vuex had one central store that could be divided into several modules. On the other hand, Pinia has no concept of a first-class module, instead, you have multiple stores. So, in this PR I have converted our Vuex store with a
dandiset
module, to a single PiniaDandisetStore
.