ms/packages/plugin/src/task.ts
MiaoWoo 8af69c98f3 refactor: plugin system & config manager
Signed-off-by: MiaoWoo <admin@yumc.pw>
2020-09-24 18:36:10 +08:00

17 lines
469 B
TypeScript

import { plugin, task } from '@ccms/api'
import { provideSingleton, Autowired } from '@ccms/container'
@provideSingleton(PluginTaskManager)
export class PluginTaskManager {
@Autowired()
private taskManager: task.TaskManager
constructor() {
process.on('plugin.after.disable', (plugin: plugin.Plugin) => this.cancelTask(plugin))
}
private cancelTask(pluginInstance: plugin.Plugin) {
this.taskManager.disable(pluginInstance)
}
}