Unsubscribed observables 27/56727/4
authorArundathi Patil <arundpil@in.ibm.com>
Wed, 18 Jul 2018 11:19:11 +0000 (16:49 +0530)
committerPatrick Brady <pb071s@att.com>
Fri, 20 Jul 2018 18:26:20 +0000 (11:26 -0700)
Unsubscribed from observables in param-name-value component. This will
release any resources that the subscription holds.

Issue-ID: APPC-1049
Change-Id: Ie3aa18bfa9d5129a26abb2f33dd2f80e1cfc8bba
Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts

index e49140d..bdf0b29 100644 (file)
@@ -3,7 +3,7 @@
 ===================================================================
 Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
 ===================================================================
-Copyright (C) 2018 IBM.
+Copyright (C) 2018 IBM Intellectual Property. All rights reserved.
 ===================================================================
 
 Unless otherwise specified, all software contained herein is licensed
@@ -23,8 +23,9 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
 ============LICENSE_END============================================
 */
 
-import { Component, ContentChildren, OnInit, QueryList, ViewChild } from '@angular/core';
+import { Component, ContentChildren, OnInit, QueryList, ViewChild, OnDestroy } from '@angular/core';
 import { ActivatedRoute, Router } from '@angular/router';
+import { Subscription } from 'rxjs/Subscription';
 import { MappingEditorService } from '../../../../shared/services/mapping-editor.service';
 import { HttpUtilService } from '../../../../shared/services/httpUtil/http-util.service';
 import { GoldenConfigurationComponent } from '../template-configuration/template-configuration.component';
@@ -50,7 +51,7 @@ declare var $: any;
     templateUrl: './param-name-value.component.html',
     styleUrls: ['./param-name-value.component.css']
 })
-export class GoldenConfigurationMappingComponent implements OnInit {
+export class GoldenConfigurationMappingComponent implements OnInit, OnDestroy {
     enableMappingSave: boolean = false;
     aceText: string = '';
     fileName: string = '';
@@ -99,13 +100,14 @@ export class GoldenConfigurationMappingComponent implements OnInit {
     @ViewChild('myInputParam') myInputParam: any;
     @ViewChild(ModalComponent) modalComponent: ModalComponent;
     @ContentChildren(Tab) tabs: QueryList<Tab>;
-    public subscription: any;
+    public subscription: Subscription;
     public item: any = {};
     vnfType: any = '';
     vnfcType: any = '';
     protocol: any = '';
     refObj: any;
     public paramsContent = localStorage['paramsContent'];
+    nameValueSubscription: Subscription;
 
     constructor(
         private buildDesignComponent: BuildDesignComponent,
@@ -167,7 +169,7 @@ export class GoldenConfigurationMappingComponent implements OnInit {
             };
         }
         this.initialAction = this.item.action;
-        this.activeRoutes.url.subscribe(UrlSegment => {
+        this.subscription = this.activeRoutes.url.subscribe(UrlSegment => {
             this.actionType = UrlSegment[0].path;
         });
 
@@ -189,6 +191,8 @@ export class GoldenConfigurationMappingComponent implements OnInit {
 
     ngOnDestroy() {
         this.prepareFileName();
+        if( this.subscription ) { this.subscription.unsubscribe(); }
+        if( this.nameValueSubscription ) { this.nameValueSubscription.unsubscribe(); }
     }
 
     //========================== End of ngOnDestroy() Method============================================
@@ -329,7 +333,7 @@ export class GoldenConfigurationMappingComponent implements OnInit {
             console.log('Retrieve name value from appc payload===>>' + payload);
             let artifactContent: any;
             this.ngProgress.start();
-            this.httpUtil.post({
+            this.nameValueSubscription = this.httpUtil.post({
                 url: environment.getDesigns,
                 data: input
             }).subscribe(resp => {
@@ -481,4 +485,4 @@ export class GoldenConfigurationMappingComponent implements OnInit {
         }
     }
 
-}
\ No newline at end of file
+}