import { IWorker } from "./interface/IWorker"; import { EWorkerType } from "./enum/EWorkerType"; import { EWorkerStatus } from "./enum/EWorkerStatus"; import { Context } from "../context/Context"; import { BaseWorker } from "./base/BaseWorker"; import { EActionPriorityType } from "../action/enum/EActionPriorityType"; export class IntervalWorker extends BaseWorker implements IWorker { constructor(context : Context){ super(); this.context = context; this.type = EWorkerType.SET_INTERVAL; this.datetime = Date.now(); this.status=EWorkerStatus.INACTIVE; } /*@overwrite*/ public run() :void { setInterval(()=>{ if(this.working == false){ if(this.actions && this.actions.length > 0){ this.working = true; this.handlerAction(this.actions[0]); } }else{ if(this.actions.length > 0 && this.actions[0].priority == EActionPriorityType.SUPER_LIFO){ this.working = true; this.handlerAction(this.actions[0]); } } }, this.time) } }