Clear the setInterval when component destroyed

This commit is contained in:
Alicia Sykes 2021-09-18 01:35:37 +01:00
parent ddce3f4c81
commit 22199394f2
1 changed files with 5 additions and 1 deletions

View File

@ -91,6 +91,7 @@ export default {
posX: undefined,
posY: undefined,
},
intervalEvent: undefined,
};
},
components: {
@ -246,9 +247,12 @@ export default {
this.kickOffCheck();
// If continious status checking is enabled, then start ever-lasting loop
if (this.statusCheckInterval > 0) {
setInterval(this.kickOffCheck, this.statusCheckInterval * 1000);
this.intervalEvent = setInterval(this.kickOffCheck, this.statusCheckInterval * 1000);
}
},
beforeDestroy() {
clearInterval(this.intervalEvent);
},
};
</script>