Browse Source

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

Eliminate OnDestroy lifecycle hook
pull/6679/head
Erwin 3 days ago
committed by GitHub
parent
commit
875f173c34
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 17
      libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.component.ts

17
libs/ui/src/lib/benchmark/benchmark-detail-dialog/benchmark-detail-dialog.component.ts

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

Loading…
Cancel
Save