]>
Commit | Line | Data |
---|---|---|
1 | export abstract class AbstractScheduler { | |
2 | ||
3 | protected abstract schedulerIntervalMs: number | |
4 | ||
5 | private interval: NodeJS.Timer | |
6 | ||
7 | enable () { | |
8 | if (!this.schedulerIntervalMs) throw new Error('Interval is not correctly set.') | |
9 | ||
10 | this.interval = setInterval(() => this.execute(), this.schedulerIntervalMs) | |
11 | } | |
12 | ||
13 | disable () { | |
14 | clearInterval(this.interval) | |
15 | } | |
16 | ||
17 | abstract execute () | |
18 | } |