Service Worker Service

class ServiceWorkerService

service-worker.service.ts
import {
  Injectable,
  Signal,
  WritableSignal,
  effect,
  inject,
  signal,
  untracked,
} from '@angular/core';
import { SwUpdate, VersionEvent } from '@angular/service-worker';
import { LocalStorageKey } from '@jet/enums/local-storage-key.enum';
import { TranslocoService } from '@jsverse/transloco';
import { Subscription } from 'rxjs';
import { AlertService } from '../alert/alert.service';
import { LoggerService } from '../logger/logger.service';
import { StorageService } from '../storage/storage.service';

@Injectable({
  providedIn: 'root',
})
export class ServiceWorkerService {
  private readonly _swUpdate = inject(SwUpdate);
  private readonly _translocoService = inject(TranslocoService);
  private readonly _alertService = inject(AlertService);
  private readonly _loggerService = inject(LoggerService);
  private readonly _storageService = inject(StorageService);

  private _isReloadPending: boolean;
  private readonly _lastUpdateCheckTimestamp: WritableSignal<string>;

  public readonly serviceWorkerUpdateSubscription: Subscription;

  public constructor() {
    // Buy to unlock
  }

  public get lastUpdateCheckTimestamp(): Signal<string> {
    // Buy to unlock
  }

  public async checkForUpdate(): Promise<void> {
    // Buy to unlock
  }

  private _subscribeToUpdates(): Subscription {
    // Buy to unlock
  }
}

Last updated

Was this helpful?