From 690e98989319b647713c31dbab209705994d4323 Mon Sep 17 00:00:00 2001 From: mauriziovitale84 Date: Mon, 15 Aug 2016 13:47:24 +0100 Subject: [PATCH] OnDestroy call unsubscribe --- .../src/components/file-uploading-dialog.component.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.ts b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.ts index 59b74fb7e7..f7ae4ddf7e 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/file-uploading-dialog.component.ts @@ -53,6 +53,9 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy { private _isDialogMinimized: boolean = false; + private listSubscription: any; + private counterSubscription: any; + constructor(private cd: ChangeDetectorRef, translate: AlfrescoTranslationService, private _uploaderService: UploadService) { @@ -61,7 +64,7 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy { ngOnInit() { if (this._uploaderService.filesUpload$) { - this._uploaderService.filesUpload$.subscribe((fileList: FileModel[]) => { + this.listSubscription = this._uploaderService.filesUpload$.subscribe((fileList: FileModel[]) => { this.filesUploadingList = fileList; if (this.filesUploadingList.length > 0) { this.isDialogActive = true; @@ -70,7 +73,7 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy { }); } if (this._uploaderService.totalCompleted$) { - this._uploaderService.totalCompleted$.subscribe((total: number) => { + this.counterSubscription = this._uploaderService.totalCompleted$.subscribe((total: number) => { this.totalCompleted = total; this.cd.detectChanges(); }); @@ -92,6 +95,8 @@ export class FileUploadingDialogComponent implements OnInit, OnDestroy { } ngOnDestroy() { + this.listSubscription.unsubscribe(); + this.counterSubscription.unsubscribe(); this.cd.detach(); } }