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