* @param {JsonObject} timerSpec The timer specification. * @param {function(): UnlistenDef=} opt_startBuilder Factory for building * start trackers for this timer. * @param {function(): UnlistenDef=} opt_stopBuilder Factory for building stop * trackers for this timer.
(timerSpec, opt_startBuilder, opt_stopBuilder)
| 979 | * trackers for this timer. |
| 980 | */ |
| 981 | constructor(timerSpec, opt_startBuilder, opt_stopBuilder) { |
| 982 | /** @private {number|undefined} */ |
| 983 | this.intervalId_ = undefined; |
| 984 | |
| 985 | userAssert( |
| 986 | 'interval' in timerSpec, |
| 987 | 'Timer interval specification required' |
| 988 | ); |
| 989 | /** @private @const {number} */ |
| 990 | this.intervalLength_ = Number(timerSpec['interval']) || 0; |
| 991 | userAssert( |
| 992 | this.intervalLength_ >= MIN_TIMER_INTERVAL_SECONDS, |
| 993 | 'Bad timer interval specification' |
| 994 | ); |
| 995 | |
| 996 | /** @private @const {number} */ |
| 997 | this.maxTimerLength_ = |
| 998 | 'maxTimerLength' in timerSpec |
| 999 | ? Number(timerSpec['maxTimerLength']) |
| 1000 | : DEFAULT_MAX_TIMER_LENGTH_SECONDS; |
| 1001 | userAssert(this.maxTimerLength_ > 0, 'Bad maxTimerLength specification'); |
| 1002 | |
| 1003 | /** @private @const {boolean} */ |
| 1004 | this.maxTimerInSpec_ = 'maxTimerLength' in timerSpec; |
| 1005 | |
| 1006 | /** @private @const {boolean} */ |
| 1007 | this.callImmediate_ = |
| 1008 | 'immediate' in timerSpec ? Boolean(timerSpec['immediate']) : true; |
| 1009 | |
| 1010 | /** @private {?function()} */ |
| 1011 | this.intervalCallback_ = null; |
| 1012 | |
| 1013 | /** @private {?UnlistenDef} */ |
| 1014 | this.unlistenStart_ = null; |
| 1015 | |
| 1016 | /** @private {?UnlistenDef} */ |
| 1017 | this.unlistenStop_ = null; |
| 1018 | |
| 1019 | /** @private @const {?function(): UnlistenDef} */ |
| 1020 | this.startBuilder_ = opt_startBuilder || null; |
| 1021 | |
| 1022 | /** @private @const {?function(): UnlistenDef} */ |
| 1023 | this.stopBuilder_ = opt_stopBuilder || null; |
| 1024 | |
| 1025 | /** @private {number|undefined} */ |
| 1026 | this.startTime_ = undefined; // milliseconds |
| 1027 | |
| 1028 | /** @private {number|undefined} */ |
| 1029 | this.lastRequestTime_ = undefined; // milliseconds |
| 1030 | } |
| 1031 | |
| 1032 | /** |
| 1033 | * @param {function()} startTimer |
nothing calls this directly
no test coverage detected