1
0
Fork 0
peertube/server/lib/schedulers/abstract-scheduler.ts
2018-08-16 09:45:51 +02:00

18 lines
389 B
TypeScript

export abstract class AbstractScheduler {
protected abstract schedulerIntervalMs: number
private interval: NodeJS.Timer
enable () {
if (!this.schedulerIntervalMs) throw new Error('Interval is not correctly set.')
this.interval = setInterval(() => this.execute(), this.schedulerIntervalMs)
}
disable () {
clearInterval(this.interval)
}
abstract execute ()
}