Skip to content

Commit

Permalink
Update LayoutCart.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
w3bdesign committed Mar 16, 2024
1 parent 9cd1e88 commit 944ab81
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions components/Layout/LayoutCart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,17 @@ watch(
}
);
if (process.client) {
onMounted(() => {
const intervalId = setInterval(() => {
if (cartChanged.value) {
cartChanged.value = false;
debouncedExecute();
}
}, 5000);
// Clear the interval when the component is unmounted to prevent memory leaks
onBeforeUnmount(() => {
clearInterval(intervalId);
});
onMounted(() => {
const intervalId = setInterval(() => {
if (cartChanged.value) {
cartChanged.value = false;
debouncedExecute();
}
}, 5000);
// Clear the interval when the component is unmounted to prevent memory leaks
onBeforeUnmount(() => {
clearInterval(intervalId);
});
}
});
</script>

0 comments on commit 944ab81

Please sign in to comment.