1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

refactor broadcaster service

This commit is contained in:
Kyle Spearrin
2018-02-10 15:22:07 -05:00
parent f072258d5c
commit b41a38afbb
4 changed files with 44 additions and 6 deletions

View File

@@ -8,6 +8,7 @@ import {
Component,
ComponentFactoryResolver,
NgZone,
OnDestroy,
OnInit,
ViewChild,
ViewContainerRef,
@@ -38,6 +39,8 @@ import { UserService } from 'jslib/abstractions/user.service';
import { ConstantsService } from 'jslib/services/constants.service';
const BroadcasterSubscriptionId = 'AppComponent';
@Component({
selector: 'app-root',
styles: [],
@@ -78,7 +81,7 @@ export class AppComponent implements OnInit {
window.onscroll = () => this.recordActivity();
window.onkeypress = () => this.recordActivity();
this.broadcasterService.subscribe((message: any) => {
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
this.ngZone.run(async () => {
switch (message.command) {
case 'loggedIn':
@@ -107,6 +110,10 @@ export class AppComponent implements OnInit {
});
}
ngOnDestroy() {
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
}
private async logOut(expired: boolean) {
const userId = await this.userService.getUserId();