2020-09-22 10:42:39 +00:00
|
|
|
import { plugin, task } from '@ccms/api'
|
2020-09-24 10:36:10 +00:00
|
|
|
import { provideSingleton, Autowired } from '@ccms/container'
|
2020-09-22 10:42:39 +00:00
|
|
|
|
|
|
|
@provideSingleton(PluginTaskManager)
|
|
|
|
export class PluginTaskManager {
|
2020-09-24 10:36:10 +00:00
|
|
|
@Autowired()
|
2020-09-22 10:42:39 +00:00
|
|
|
private taskManager: task.TaskManager
|
|
|
|
|
|
|
|
constructor() {
|
2020-11-13 01:40:34 +00:00
|
|
|
process.on('plugin.after.disable', this.cancelTask.bind(this))
|
2020-09-22 10:42:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private cancelTask(pluginInstance: plugin.Plugin) {
|
|
|
|
this.taskManager.disable(pluginInstance)
|
|
|
|
}
|
|
|
|
}
|