export default class Interval { handle: number | undefined; method; time; static begin(method: Function, time: number) { const instance = new Interval(method, time); instance.start(); return instance; } constructor(method: Function, time: number) { this.method = method; this.time = time; } start() { this.stop(); this.handle = setInterval(this.method, this.time); } stop() { clearInterval(this.handle); } }