diff options
author | Arundathi Patil <arundpil@in.ibm.com> | 2018-07-17 16:05:00 +0530 |
---|---|---|
committer | Takamune Cho <tc012c@att.com> | 2018-07-23 12:53:37 +0000 |
commit | 897c4b711252ac4bdc8301458005ec0786a5bd09 (patch) | |
tree | 123476e6a5bc54e0ad68b5aad1ee2fa1826ff809 /src | |
parent | fe5bf3a03823b573f66a29b96d34d911b1c2fdfe (diff) |
unsubscribed from observables
Unsubscribed from observables in ngOndestroy method of myvnfs component.
This will release the resources held by the subscription.
Issue-ID: APPC-1049
Change-Id: I7cc7bd5aabeeb20934332541b99314a611d66f93
Signed-off-by: Arundathi Patil<arundpil@in.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/app/vnfs/myvnfs/myvnfs.component.ts | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/src/app/vnfs/myvnfs/myvnfs.component.ts b/src/app/vnfs/myvnfs/myvnfs.component.ts index c747a7e..1a27135 100644 --- a/src/app/vnfs/myvnfs/myvnfs.component.ts +++ b/src/app/vnfs/myvnfs/myvnfs.component.ts @@ -21,9 +21,10 @@ limitations under the License. ============LICENSE_END============================================ */ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, OnDestroy } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { HttpUtilService } from '../../shared/services/httpUtil/http-util.service'; +import { Subscription } from 'rxjs/Subscription'; import { MappingEditorService } from '../../shared/services/mapping-editor.service'; import { ParamShareService } from '../../shared/services/paramShare.service'; import { environment } from '../../../environments/environment'; @@ -32,7 +33,7 @@ import { NgProgress } from 'ngx-progressbar'; import { NotificationsService } from 'angular2-notifications'; @Component({ selector: 'app-myvnfs', templateUrl: './myvnfs.component.html', styleUrls: ['./myvnfs.component.css'] }) -export class MyvnfsComponent implements OnInit { +export class MyvnfsComponent implements OnInit, OnDestroy { vnfData: Array<Object> = []; sortOrder = false; noData = true; @@ -42,15 +43,16 @@ export class MyvnfsComponent implements OnInit { vnfType: any; vnfcType: any; options = { - timeOut: 1000, - showProgressBar: true, - pauseOnHover: true, - clickToClose: true, - maxLength: 200 + timeOut: 1000, + showProgressBar: true, + pauseOnHover: true, + clickToClose: true, + maxLength: 200 } + subscription: Subscription; - constructor (private paramShareService: ParamShareService, private ngProgress: NgProgress, private httpUtil: HttpUtilService, private router: Router, private activeROute: ActivatedRoute, - private mappingEditorService: MappingEditorService, private modalService: NgbModal,private nService: NotificationsService) { + constructor(private paramShareService: ParamShareService, private ngProgress: NgProgress, private httpUtil: HttpUtilService, private router: Router, private activeROute: ActivatedRoute, + private mappingEditorService: MappingEditorService, private modalService: NgbModal, private nService: NotificationsService) { } ngOnInit() { @@ -76,14 +78,18 @@ export class MyvnfsComponent implements OnInit { this.clearCache(); } + ngOnDestroy() { + if (this.subscription) { this.subscription.unsubscribe() }; + } + getArtifacts(data) { this.ngProgress.start(); - this.httpUtil.post({ + this.subscription = this.httpUtil.post({ url: environment.getDesigns, data: data }) .subscribe(resp => { - console.log("resp:",resp); + console.log("resp:", resp); const tempObj = JSON.parse(resp.output.data.block); this.vnfData = tempObj.designInfo; if (this.vnfData == undefined || this.vnfData == null || this.vnfData.length == 0) { @@ -96,13 +102,14 @@ export class MyvnfsComponent implements OnInit { console.log(this.noData); this.ngProgress.done(); } - , - error => { - - this.nService.error("Error", "Error in connecting to APPC Server")} - - ); - + , + error => { + + this.nService.error("Error", "Error in connecting to APPC Server") + } + + ); + this.filter = ['vnf-type', 'vnfc-type', 'artifact-name']; setTimeout(() => { this.ngProgress.done(); |