Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Task/eliminate OnDestroy lifecycle hook from benchmark detail dialog component (#6675)

Erwin875f173c34ec
diff --git a/libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.component.ts b/libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.component.ts
index 2f4c182882..0c75b59549 100644
--- a/libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.component.ts
+++ b/libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.component.ts
@@ -12,18 +12,17 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
+ DestroyRef,
Inject,
- OnDestroy,
OnInit
} from '@angular/core';
+import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import {
MAT_DIALOG_DATA,
MatDialogModule,
MatDialogRef
} from '@angular/material/dialog';
import { format } from 'date-fns';
-import { Subject } from 'rxjs';
-import { takeUntil } from 'rxjs/operators';
import { GfLineChartComponent } from '../../line-chart/line-chart.component';
import { GfValueComponent } from '../../value/value.component';
@@ -44,16 +43,15 @@ import { BenchmarkDetailDialogParams } from './interfaces/interfaces';
styleUrls: ['./benchmark-detail-dialog.component.scss'],
templateUrl: 'benchmark-detail-dialog.html'
})
-export class GfBenchmarkDetailDialogComponent implements OnDestroy, OnInit {
+export class GfBenchmarkDetailDialogComponent implements OnInit {
public assetProfile: AdminMarketDataDetails['assetProfile'];
public historicalDataItems: LineChartItem[];
public value: number;
- private unsubscribeSubject = new Subject<void>();
-
public constructor(
private changeDetectorRef: ChangeDetectorRef,
private dataService: DataService,
+ private destroyRef: DestroyRef,
public dialogRef: MatDialogRef<GfBenchmarkDetailDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: BenchmarkDetailDialogParams
) {}
@@ -64,7 +62,7 @@ export class GfBenchmarkDetailDialogComponent implements OnDestroy, OnInit {
dataSource: this.data.dataSource,
symbol: this.data.symbol
})
- .pipe(takeUntil(this.unsubscribeSubject))
+ .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(({ assetProfile, marketData }) => {
this.assetProfile = assetProfile;
@@ -88,9 +86,4 @@ export class GfBenchmarkDetailDialogComponent implements OnDestroy, OnInit {
public onClose() {
this.dialogRef.close();
}
-
- public ngOnDestroy() {
- this.unsubscribeSubject.next();
- this.unsubscribeSubject.complete();
- }
}