Unsubscribed observables
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>
diff --git a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts
index e49140d..bdf0b29 100644
--- a/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts
+++ b/src/app/vnfs/build-artifacts/template-holder/param-name-value/param-name-value.component.ts
@@ -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 @@
============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 @@
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 @@
@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 @@
};
}
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 @@
ngOnDestroy() {
this.prepareFileName();
+ if( this.subscription ) { this.subscription.unsubscribe(); }
+ if( this.nameValueSubscription ) { this.nameValueSubscription.unsubscribe(); }
}
//========================== End of ngOnDestroy() Method============================================
@@ -329,7 +333,7 @@
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 @@
}
}
-}
\ No newline at end of file
+}