Answer the question
In order to leave comments, you need to log in
How to synchronize store and back-end?
I am making a bitrix cart on vuejs using vuex.
The question is at what point is it better to send ajax requests when changing the quantity of goods in the cart?
With each click on the "+" of the product, I don’t feel like it at all, because they can actively click on it ...
Purpose: the user went to the basket, increased / decreased the number of goods, deleted something. Reloaded the page. All information must remain. That is, its actions must be processed on the server.
Suggest options.
How good are the options:
1. Synchronize the basket state at intervals.
2. Synchronize the state on the onunload event.
3. Write a click handler that will regulate the frequency of requests (I really don’t want to).
Answer the question
In order to leave comments, you need to log in
Do I understand the goals correctly?
How good are the options:
1. Synchronize the bucket state at intervals.
2. Synchronize the state on the onunload event
3. Write a click handler that will regulate the frequency of requests (I really don’t want to)
methods: {
syncCart: debounce(function() {
...
}),
},
watch: {
'$store.state.cart': {
immediate: true,
deep: true,
handler: 'syncCart',
},
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question