@observertc/observer-js
Version:
Server Side NodeJS Library for processing ObserveRTC Samples
19 lines (15 loc) • 496 B
text/typescript
import { Updater } from './Updater';
export class OnIntervalUpdater implements Updater {
readonly name = 'OnIntervalUpdater';
readonly description = 'Call the update() method given in the constructor once the interval elapsed';
public timer: ReturnType<typeof setInterval>;
public constructor(
intervalInMs: number,
private readonly _update: () => void,
) {
this.timer = setInterval(() => this._update(), intervalInMs);
}
public close(): void {
clearInterval(this.timer);
}
}