1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 3x 5x 5x 5x 2x 2x | export default class GlobalTimer { constructor() { this._timerHandler = undefined; } invoke(callback, duration) { this.cancel(); this._timerHandler = setTimeout(callback, duration); } cancel() { if (this._timerHandler) { clearTimeout(this._timerHandler); this._timerHandler = undefined; } } } |