2018-01-11 02:35:50 -06:00
|
|
|
export abstract class AbstractScheduler {
|
|
|
|
|
2018-06-14 11:06:56 -05:00
|
|
|
protected abstract schedulerIntervalMs: number
|
|
|
|
|
2018-01-11 02:35:50 -06:00
|
|
|
private interval: NodeJS.Timer
|
|
|
|
|
|
|
|
enable () {
|
2018-06-14 11:06:56 -05:00
|
|
|
if (!this.schedulerIntervalMs) throw new Error('Interval is not correctly set.')
|
|
|
|
|
|
|
|
this.interval = setInterval(() => this.execute(), this.schedulerIntervalMs)
|
2018-01-11 02:35:50 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
disable () {
|
|
|
|
clearInterval(this.interval)
|
|
|
|
}
|
|
|
|
|
2018-08-16 02:45:51 -05:00
|
|
|
abstract execute ()
|
2018-01-11 02:35:50 -06:00
|
|
|
}
|