I have the following component:
@Component({
selector: 'app-columns-list-configurations',
templateUrl: 'columns.list.configurations.component.html'
})
export class ColumnsListConfigurationsComponent implements OnInit, OnDestroy {
private descriptionWasChanged: EventEmitter<ATreeExpanderItem> = new EventEmitter<ATreeExpanderItem>();
constructor() {}
ngOnInit(): void {
this.descriptionWasChanged.subscribe((item: ATreeExpanderItem) => {
this.changeDescription(item as ColumnListModel);
let localItems: Array<ColumnListModel> = this.deepCopy(this.items);
this.itemsHasChanged(localItems);
});
}
private deepCopy(columns: Array<ColumnListModel>): Array<ColumnListModel> {
let newColumns: Array<ColumnListModel> = new Array<ColumnListModel>();
columns.forEach((column: ColumnListModel) => {
let newColumn: ColumnListModel = new ColumnListModel();
newColumn.set(column, this.deepCopy(column.items as Array<ColumnListModel>));
newColumns.push(newColumn);
});
return newColumns;
}
}
itemsHasChanged(...) {...}
I have a function deepCopy
that tries to make an array deep copy and I have a event subscription descriptionWasChanged
that each time that is an emit is made, makes a deepCopy and passes the array copy to the itemsHasChanged
function.
Could I have memory leak problems:
- Each time the
descriptionWasChanged.subscribe
finishes is work? - Each time the component
ColumnsListConfigurationsComponent
is destroyed?
Comments
Post a Comment