const logger = require('../kit/logger-kit') class Task { context constructor(delayTime, initFun, onTickFun) { this.delayTime = delayTime this.init = initFun this.onTick = onTickFun } async Start() { const task = this logger.info('Init context or others.') await this.init() logger.info('Dida dida dida, on tick, on tick...') this.interval = setInterval(async () => { try { await task.onTick() } catch (e) { logger.error(e) } }, this.delayTime) } async Stop() { clearInterval(this.interval) } } module.exports = Task