mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-01 14:41:32 +00:00
fixes for memory leaks and multiple subscriptions (#3456)
* fix content action memory leaks * memory leak fixes for demo shell
This commit is contained in:
committed by
Eugenio Romano
parent
beeb7bd369
commit
346dff436d
@@ -15,13 +15,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, OnChanges, OnInit, ViewChild } from '@angular/core';
|
||||
import { Component, Input, OnChanges, OnInit, ViewChild, OnDestroy } from '@angular/core';
|
||||
import { ProcessInstance, ProcessService ,
|
||||
ProcessAttachmentListComponent, ProcessUploadService } from '@alfresco/adf-process-services';
|
||||
import { UploadService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { PreviewService } from '../../services/preview.service';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
|
||||
export function processUploadServiceFactory(api: AlfrescoApiService, config: AppConfigService) {
|
||||
return new ProcessUploadService(api, config);
|
||||
@@ -40,7 +41,7 @@ export function processUploadServiceFactory(api: AlfrescoApiService, config: App
|
||||
]
|
||||
})
|
||||
|
||||
export class ProcessAttachmentsComponent implements OnInit, OnChanges {
|
||||
export class ProcessAttachmentsComponent implements OnInit, OnChanges, OnDestroy {
|
||||
|
||||
@ViewChild('processAttachList')
|
||||
processAttachList: ProcessAttachmentListComponent;
|
||||
@@ -50,6 +51,8 @@ export class ProcessAttachmentsComponent implements OnInit, OnChanges {
|
||||
|
||||
processInstance: ProcessInstance;
|
||||
|
||||
private subscriptions: Subscription[] = [];
|
||||
|
||||
constructor(
|
||||
private uploadService: UploadService,
|
||||
private processService: ProcessService,
|
||||
@@ -57,7 +60,11 @@ export class ProcessAttachmentsComponent implements OnInit, OnChanges {
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.uploadService.fileUploadComplete.subscribe(value => this.onFileUploadComplete(value.data));
|
||||
this.subscriptions.push(
|
||||
this.uploadService.fileUploadComplete.subscribe(
|
||||
value => this.onFileUploadComplete(value.data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
@@ -69,6 +76,11 @@ export class ProcessAttachmentsComponent implements OnInit, OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(subscription => subscription.unsubscribe());
|
||||
this.subscriptions = [];
|
||||
}
|
||||
|
||||
onFileUploadComplete(content: any) {
|
||||
this.processAttachList.add(content);
|
||||
}
|
||||
|
Reference in New Issue
Block a user