Merge "Cancel polling task after component unmount"
This commit is contained in:
@@ -67,6 +67,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
job: null,
|
||||
pending_task: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -77,6 +78,12 @@ export default {
|
||||
created() {
|
||||
this.updateStatus()
|
||||
},
|
||||
unmounted() {
|
||||
if (this.pending_task) {
|
||||
clearTimeout(this.pending_task);
|
||||
this.pending_task = null;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async updateStatus() {
|
||||
// fetch job (by id) and set local job data
|
||||
@@ -101,7 +108,7 @@ export default {
|
||||
console.log(err)
|
||||
}
|
||||
if (this.job.status == 'Running') {
|
||||
setTimeout(this.updateStatus, 1000)
|
||||
this.pending_task = setTimeout(this.updateStatus, 1000)
|
||||
}
|
||||
},
|
||||
updateConfig() {
|
||||
|
||||
Reference in New Issue
Block a user