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