UNPKG

@overwolf/overwolf-api-ts

Version:

utilities and wrappers for common Overwolf API tasks

32 lines (31 loc) 819 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Timer = void 0; class Timer { static async wait(intervalInMS) { return new Promise(resolve => { setTimeout(resolve, intervalInMS); }); } constructor(delegate, id) { this._timerId = null; this.handleTimerEvent = () => { this._timerId = null; this._delegate.onTimer(this._id); }; this._delegate = delegate; this._id = id; } start(intervalInMS) { this.stop(); this._timerId = setTimeout(this.handleTimerEvent, intervalInMS); } stop() { if (this._timerId == null) { return; } clearTimeout(this._timerId); this._timerId = null; } } exports.Timer = Timer;