cleaning task manager

This commit is contained in:
les
2020-02-10 12:00:16 +01:00
parent 6d72a7b967
commit a7a745e04f
3 changed files with 8 additions and 5 deletions

View File

@@ -67,10 +67,14 @@ class TaskManager {
if (!this.tasks.length) {
return
}
const removableTasks = this.tasks.filter(t => t.removable).map(t => t.process())
this.tasks = this.tasks.filter(t => !t.removable)
// process all tasks
const tasks = this.tasks.map(t => t.process())
return Promise.all(tasks.concat(removableTasks))
// remove removable tasks
this.tasks = this.tasks.filter(t => !t.removable)
return Promise.all(tasks)
}
async tick () {