Fixes for Firefox.

This commit is contained in:
Dermot Duffy
2022-03-05 08:58:01 -08:00
parent b947df3e14
commit fed2cba89a
2 changed files with 67 additions and 12 deletions
+6 -5
View File
@@ -32,6 +32,7 @@ export class CachedValueController<T> implements ReactiveController {
*/
public updateValue(): void {
this._value = this._callback();
this._startTimer();
}
/**
@@ -39,12 +40,13 @@ export class CachedValueController<T> implements ReactiveController {
*/
public clearValue(): void {
this._value = undefined;
this._stopTimer();
}
/**
* Disable the timer.
*/
public stopTimer(): void {
protected _stopTimer(): void {
clearInterval(this._timerID);
this._timerID = undefined;
}
@@ -52,8 +54,8 @@ export class CachedValueController<T> implements ReactiveController {
/**
* Enable the timer. Repeated calls will have no effect.
*/
public startTimer(): void {
this.stopTimer();
protected _startTimer(): void {
this._stopTimer();
if (this._timerSeconds > 0) {
this._timerID = window.setInterval(() => {
this.updateValue();
@@ -67,7 +69,6 @@ export class CachedValueController<T> implements ReactiveController {
*/
hostConnected(): void {
this.updateValue();
this.startTimer();
this._host.requestUpdate();
}
@@ -75,6 +76,6 @@ export class CachedValueController<T> implements ReactiveController {
* Host has disconnected from the cache.
*/
hostDisconnected(): void {
this.stopTimer();
this.clearValue();
}
}