Mirror navigator online flag in observable state

This commit is contained in:
Willem Dantuma
2020-07-22 08:52:41 +02:00
parent 31d01c75c5
commit 2790ae74e7
3 changed files with 42 additions and 4 deletions

View File

@@ -98,13 +98,23 @@ export class AppComponent implements OnInit, OnDestroy {
}
@HostListener('document:keyup', ['$event'])
keyUp(event: KeyboardEvent) {
onKeyUp(event: KeyboardEvent) {
let x = event.keyCode;
if (x === 27) {
this.store.dispatch(new commonActions.Escape(true,false));
}
}
@HostListener('window:online', ['$event'])
onOnline(event: Event) {
this.store.dispatch(new commonActions.Online());
}
@HostListener('window:offline', ['$event'])
onOffline(event: Event) {
this.store.dispatch(new commonActions.Offline());
}
ngOnDestroy() {
// Subscription clean-up
if(this.routerSub$) this.routerSub$.unsubscribe();