Asynchronous initialization and data recovery #2917
Unanswered
hzdjulytech
asked this question in
Help and Questions
Replies: 0 comments
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
What do I do to make sure that the data is properly recovered before it's served out, that is, to make sure that the init function is executed and the init function might be an asynchronous function like reading data from indexDB.
`
export const useUserStore = defineStore('user', {
state: () => {
return {
token: null as DataWithExpires | null,
},
actions:{
async init(){
// read from indexdb
}
}
}
`
It would be too inelegant to check initialization every place where you read it
Beta Was this translation helpful? Give feedback.
All reactions