From 0883298cf1b697cb5dea27ad2d2c69316a6c7ff6 Mon Sep 17 00:00:00 2001 From: Erwin <111194281+Erwin-N@users.noreply.github.com> Date: Sat, 14 Mar 2026 17:48:44 +0100 Subject: [PATCH] Task/eliminate OnDestroy lifecycle hook from data provider status component (#6566) * Eliminate OnDestroy lifecycle hook --- .../data-provider-status.component.ts | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/apps/client/src/app/components/data-provider-status/data-provider-status.component.ts b/apps/client/src/app/components/data-provider-status/data-provider-status.component.ts index e44e81be9..a77d65961 100644 --- a/apps/client/src/app/components/data-provider-status/data-provider-status.component.ts +++ b/apps/client/src/app/components/data-provider-status/data-provider-status.component.ts @@ -4,13 +4,14 @@ import { CommonModule } from '@angular/common'; import { ChangeDetectionStrategy, Component, + DestroyRef, Input, - OnDestroy, OnInit } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import type { DataSource } from '@prisma/client'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; -import { catchError, map, type Observable, of, Subject, takeUntil } from 'rxjs'; +import { catchError, map, type Observable, of } from 'rxjs'; import { DataProviderStatus } from './interfaces/interfaces'; @@ -20,14 +21,15 @@ import { DataProviderStatus } from './interfaces/interfaces'; selector: 'gf-data-provider-status', templateUrl: './data-provider-status.component.html' }) -export class GfDataProviderStatusComponent implements OnDestroy, OnInit { +export class GfDataProviderStatusComponent implements OnInit { @Input() dataSource: DataSource; public status$: Observable; - private unsubscribeSubject = new Subject(); - - public constructor(private dataService: DataService) {} + public constructor( + private dataService: DataService, + private destroyRef: DestroyRef + ) {} public ngOnInit() { this.status$ = this.dataService @@ -39,12 +41,7 @@ export class GfDataProviderStatusComponent implements OnDestroy, OnInit { catchError(() => { return of({ isHealthy: false }); }), - takeUntil(this.unsubscribeSubject) + takeUntilDestroyed(this.destroyRef) ); } - - public ngOnDestroy() { - this.unsubscribeSubject.next(); - this.unsubscribeSubject.complete(); - } }