From bce4e9a96ef0d5f6a6b41d99b658885cccd08b4b Mon Sep 17 00:00:00 2001 From: ztimson Date: Sat, 24 Aug 2019 19:30:18 -0400 Subject: [PATCH] Detect updates --- src/app/app.component.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index d0198ee..63409a2 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,7 +1,13 @@ import { Component } from '@angular/core'; +import {MatSnackBar} from "@angular/material/snack-bar"; +import {SwUpdate} from "@angular/service-worker"; @Component({ selector: 'app-root', templateUrl: 'app.component.html' }) -export class AppComponent { } +export class AppComponent { + constructor(private snackbar: MatSnackBar, private update: SwUpdate) { + update.available.subscribe(() => snackbar.open('Update Available!! 🚀', 'Reload').onAction().subscribe(() => update.activateUpdate())) + } +}