O
O
olezhenka2018-04-24 11:43:33
Vue.js
olezhenka, 2018-04-24 11:43:33

Where to run the main action from vuex?

I have an action that gets all the information about the user from the site's API. After receiving the data, this action naturally changes the state of the application and it needs to run before the page loads in order for me to do the loading animation. I think MB in App.vue should be stuffed into created, but maybe there is something more elegant already ready for this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kulakov, 2018-04-24
@olezhenka

Well, it's a normal choice. You can put it in a separate file so that the code looks cleaner.
If vue-router is used, then you can put a flag in the beforeEach hook so that this action is called only once.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question