Skip to content

Instantly share code, notes, and snippets.

@webmaxru
Last active November 4, 2017 15:30
Show Gist options
  • Select an option

  • Save webmaxru/e9a37c695d0ca265505338cdc87993d3 to your computer and use it in GitHub Desktop.

Select an option

Save webmaxru/e9a37c695d0ca265505338cdc87993d3 to your computer and use it in GitHub Desktop.
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