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

onDestroy needed for broadcast subscriptions

This commit is contained in:
Chad Scharf
2020-11-04 14:00:44 -05:00
parent c9c6a11390
commit 97e982bf01
7 changed files with 40 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
import {
Component,
ComponentFactoryResolver,
OnDestroy,
NgZone,
ViewChild,
ViewContainerRef,
@@ -31,7 +32,7 @@ const BroadcasterSubscriptionId = 'LoginComponent';
selector: 'app-login',
templateUrl: 'login.component.html',
})
export class LoginComponent extends BaseLoginComponent {
export class LoginComponent extends BaseLoginComponent implements OnDestroy {
@ViewChild('environment', { read: ViewContainerRef, static: true }) environmentModal: ViewContainerRef;
showingModal = false;
@@ -63,6 +64,10 @@ export class LoginComponent extends BaseLoginComponent {
});
}
ngOnDestroy() {
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
}
settings() {
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
const modal = this.environmentModal.createComponent(factory).instance;