Last active
November 4, 2017 15:30
-
-
Save webmaxru/e9a37c695d0ca265505338cdc87993d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { SwUpdate } from '@angular/service-worker'; | |
| ... | |
| export class ControlBroadcastComponent implements OnInit { | |
| constructor(private swUpdate: SwUpdate, ...) { } | |
| ngOnInit() { | |
| this.swUpdate.available.subscribe(event => { | |
| console.log('[App] Update available: current version is', event.current, 'available version is', event.available); | |
| let snackBarRef = this.snackBar.open('Newer version of the app is available', 'Refresh'); | |
| snackBarRef.onAction().subscribe(() => { | |
| this.winRef.nativeWindow.location.reload() | |
| }); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment