Skip to content

Commit

Permalink
perf(CRUD): remove memory leak (#351)
Browse files Browse the repository at this point in the history
Closes #349
  • Loading branch information
simply10w authored and timdeschryver committed Sep 21, 2018
1 parent 283fe9b commit 5f3c687
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/examples/crud/components/crud.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { v4 as uuid } from 'uuid';
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, OnDestroy } from '@angular/core';
import { FormBuilder, NgForm } from '@angular/forms';
import { takeUntil } from 'rxjs/operators';
import { Subject, Observable } from 'rxjs';
Expand All @@ -22,7 +22,7 @@ import { selectSelectedBook, selectAllBooks } from '../books.selectors';
templateUrl: './crud.component.html',
styleUrls: ['./crud.component.scss']
})
export class CrudComponent implements OnInit {
export class CrudComponent implements OnInit, OnDestroy {
private unsubscribe$: Subject<void> = new Subject<void>();
routeAnimationsElements = ROUTE_ANIMATIONS_ELEMENTS;

Expand All @@ -49,6 +49,11 @@ export class CrudComponent implements OnInit {
.subscribe(book => (this.selectedBook = book));
}

ngOnDestroy() {
this.unsubscribe$.next();
this.unsubscribe$.complete();
}

select(id: string) {
this.store.dispatch(new ActionBooksSelect({ id }));
this.isEditing = false;
Expand Down

0 comments on commit 5f3c687

Please sign in to comment.