Browse Source

Eliminate OnDestroy hook

pull/6671/head
Erwin-N 2 months ago
parent
commit
7e365d67fa
  1. 18
      libs/ui/src/lib/activities-table/activities-table.component.ts

18
libs/ui/src/lib/activities-table/activities-table.component.ts

@ -19,9 +19,9 @@ import {
CUSTOM_ELEMENTS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA,
ChangeDetectionStrategy, ChangeDetectionStrategy,
Component, Component,
DestroyRef,
EventEmitter, EventEmitter,
Input, Input,
OnDestroy,
OnInit, OnInit,
Output, Output,
ViewChild, ViewChild,
@ -29,6 +29,7 @@ import {
inject, inject,
input input
} from '@angular/core'; } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { MatCheckboxModule } from '@angular/material/checkbox'; import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatMenuModule } from '@angular/material/menu'; import { MatMenuModule } from '@angular/material/menu';
@ -63,7 +64,6 @@ import {
trashOutline trashOutline
} from 'ionicons/icons'; } from 'ionicons/icons';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { Subject, takeUntil } from 'rxjs';
import { GfActivityTypeComponent } from '../activity-type/activity-type.component'; import { GfActivityTypeComponent } from '../activity-type/activity-type.component';
import { GfEntityLogoComponent } from '../entity-logo/entity-logo.component'; import { GfEntityLogoComponent } from '../entity-logo/entity-logo.component';
@ -94,9 +94,7 @@ import { GfValueComponent } from '../value/value.component';
styleUrls: ['./activities-table.component.scss'], styleUrls: ['./activities-table.component.scss'],
templateUrl: './activities-table.component.html' templateUrl: './activities-table.component.html'
}) })
export class GfActivitiesTableComponent export class GfActivitiesTableComponent implements AfterViewInit, OnInit {
implements AfterViewInit, OnDestroy, OnInit
{
@Input() baseCurrency: string; @Input() baseCurrency: string;
@Input() deviceType: string; @Input() deviceType: string;
@Input() hasActivities: boolean; @Input() hasActivities: boolean;
@ -186,9 +184,8 @@ export class GfActivitiesTableComponent
}); });
private readonly notificationService = inject(NotificationService); private readonly notificationService = inject(NotificationService);
private readonly unsubscribeSubject = new Subject<void>();
public constructor() { public constructor(private destroyRef: DestroyRef) {
addIcons({ addIcons({
alertCircleOutline, alertCircleOutline,
calendarClearOutline, calendarClearOutline,
@ -209,7 +206,7 @@ export class GfActivitiesTableComponent
if (this.showCheckbox()) { if (this.showCheckbox()) {
this.toggleAllRows(); this.toggleAllRows();
this.selectedRows.changed this.selectedRows.changed
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((selectedRows) => { .subscribe((selectedRows) => {
this.selectedActivities.emit(selectedRows.source.selected); this.selectedActivities.emit(selectedRows.source.selected);
}); });
@ -342,9 +339,4 @@ export class GfActivitiesTableComponent
this.selectedActivities.emit(this.selectedRows.selected); this.selectedActivities.emit(this.selectedRows.selected);
} }
public ngOnDestroy() {
this.unsubscribeSubject.next();
this.unsubscribeSubject.complete();
}
} }

Loading…
Cancel
Save