Skip to content

Commit c3ed46c

Browse files
committed
Angular PWA Course
1 parent 61820e9 commit c3ed46c

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

src/app/app.component.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {Component, OnInit} from '@angular/core';
22
import {Observable} from "rxjs/Observable";
33
import {SwUpdate} from "@angular/service-worker";
4+
import {MatSnackBar} from "@angular/material/snack-bar";
45

56
@Component({
67
selector: 'app-root',
@@ -10,14 +11,24 @@ import {SwUpdate} from "@angular/service-worker";
1011
export class AppComponent implements OnInit {
1112

1213

13-
constructor(private swUpdate:SwUpdate) {
14+
constructor(private swUpdate:SwUpdate, private snackBar: MatSnackBar) {
1415

1516
}
1617

1718
ngOnInit() {
1819

1920
this.swUpdate.checkForUpdate();
2021

22+
this.swUpdate.available.subscribe(() => {
23+
24+
console.log("New Version available...");
25+
26+
const snackRef = this.snackBar.open("New Version Available!", "Click To Use New Version");
27+
28+
snackRef.onAction().subscribe(() => window.location.reload());
29+
30+
});
31+
2132
}
2233

2334

src/app/app.module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {Router, RouterModule} from "@angular/router";
1313

1414
import {environment} from '../environments/environment.prod';
1515
import {ServiceWorkerModule} from '@angular/service-worker';
16+
import {MatSnackBarModule} from '@angular/material/snack-bar';
1617

1718
import 'rxjs/add/operator/switchMap';
1819
import 'rxjs/add/operator/map';
@@ -22,6 +23,7 @@ import 'rxjs/add/operator/filter';
2223
import 'rxjs/add/operator/catch';
2324
import 'rxjs/add/operator/first';
2425
import 'rxjs/add/observable/of';
26+
import {BrowserAnimationsModule} from "@angular/platform-browser/animations";
2527

2628

2729

@@ -34,7 +36,9 @@ import 'rxjs/add/observable/of';
3436
imports: [
3537
BrowserModule,
3638
HttpClientModule,
39+
BrowserAnimationsModule,
3740
RouterModule.forRoot(routesConfig),
41+
MatSnackBarModule,
3842
ReactiveFormsModule,
3943
ServiceWorkerModule.register('/ngsw-worker.js', { enabled: environment.production })
4044
],

src/app/lessons/lessons.component.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11

22
<div class="lessons-list-container v-h-center-block-parent" >
33

4-
5-
64
<div class="buttons">
75
<button class="button button-danger" (click)="loadLessons()">Reload Lessons</button>
86
</div>
97

10-
<h2>All Lessons - V7</h2>
8+
<h2>All Lessons - V15</h2>
119

1210
<table class="table lessons-list card card-strong">
1311
<tbody>

src/styles.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
/* You can add global styles to this file, and also import other style files */
2+
3+
4+
5+
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
6+
7+

0 commit comments

Comments
 (0)