Answer the question
In order to leave comments, you need to log in
How to architecturally determine whether a request is needed or not and after the request to update different data depending on the place of the call?
I have a form inside a modal filled with data that comes from the server. You can open this modal from 2 places. In one place, the data for displaying the modal is always there, as it is requested for other purposes initially when the page is opened. In the second place, the data may or may not be.
Now in vuex I made a check through if there is data, the necessary data in the state or not. If not, then I request them, something like this:
actions: {
openModalwithForm({commit, state, dispatch}) {
commit('modalFormVisible', true);
if (state.formData) dispatch('getFormData);
},
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question