Browse Source

Task/add destroyRef explicitly to lib components (#6559)

* Add destroyRef explicitly
pull/6575/head^2
Thomas Kaul 7 days ago
committed by GitHub
parent
commit
397f60756f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      libs/ui/src/lib/activities-filter/activities-filter.component.ts
  2. 26
      libs/ui/src/lib/fire-calculator/fire-calculator.component.ts

5
libs/ui/src/lib/activities-filter/activities-filter.component.ts

@ -7,6 +7,7 @@ import {
CUSTOM_ELEMENTS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA,
ChangeDetectionStrategy, ChangeDetectionStrategy,
Component, Component,
DestroyRef,
ElementRef, ElementRef,
Input, Input,
OnChanges, OnChanges,
@ -69,9 +70,9 @@ export class GfActivitiesFilterComponent implements OnChanges {
protected selectedFilters: Filter[] = []; protected selectedFilters: Filter[] = [];
protected readonly separatorKeysCodes: number[] = [ENTER, COMMA]; protected readonly separatorKeysCodes: number[] = [ENTER, COMMA];
public constructor() { public constructor(private destroyRef: DestroyRef) {
this.searchControl.valueChanges this.searchControl.valueChanges
.pipe(takeUntilDestroyed()) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((filterOrSearchTerm) => { .subscribe((filterOrSearchTerm) => {
if (filterOrSearchTerm) { if (filterOrSearchTerm) {
const searchTerm = const searchTerm =

26
libs/ui/src/lib/fire-calculator/fire-calculator.component.ts

@ -12,6 +12,7 @@ import {
ChangeDetectionStrategy, ChangeDetectionStrategy,
ChangeDetectorRef, ChangeDetectorRef,
Component, Component,
DestroyRef,
ElementRef, ElementRef,
Input, Input,
OnChanges, OnChanges,
@ -123,6 +124,7 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy {
public constructor( public constructor(
private changeDetectorRef: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
private destroyRef: DestroyRef,
private fireCalculatorService: FireCalculatorService, private fireCalculatorService: FireCalculatorService,
private formBuilder: FormBuilder private formBuilder: FormBuilder
) { ) {
@ -135,13 +137,13 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy {
); );
this.calculatorForm.valueChanges this.calculatorForm.valueChanges
.pipe(takeUntilDestroyed()) .pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(() => { .subscribe(() => {
this.initialize(); this.initialize();
}); });
this.calculatorForm.valueChanges this.calculatorForm.valueChanges
.pipe(debounceTime(500), takeUntilDestroyed()) .pipe(debounceTime(500), takeUntilDestroyed(this.destroyRef))
.subscribe(() => { .subscribe(() => {
const { projectedTotalAmount, retirementDate } = const { projectedTotalAmount, retirementDate } =
this.calculatorForm.getRawValue(); this.calculatorForm.getRawValue();
@ -156,7 +158,10 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy {
this.calculatorForm this.calculatorForm
.get('annualInterestRate') .get('annualInterestRate')
?.valueChanges.pipe(debounceTime(500), takeUntilDestroyed()) ?.valueChanges.pipe(
debounceTime(500),
takeUntilDestroyed(this.destroyRef)
)
.subscribe((annualInterestRate) => { .subscribe((annualInterestRate) => {
if (annualInterestRate !== null) { if (annualInterestRate !== null) {
this.annualInterestRateChanged.emit(annualInterestRate); this.annualInterestRateChanged.emit(annualInterestRate);
@ -164,7 +169,10 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy {
}); });
this.calculatorForm this.calculatorForm
.get('paymentPerPeriod') .get('paymentPerPeriod')
?.valueChanges.pipe(debounceTime(500), takeUntilDestroyed()) ?.valueChanges.pipe(
debounceTime(500),
takeUntilDestroyed(this.destroyRef)
)
.subscribe((savingsRate) => { .subscribe((savingsRate) => {
if (savingsRate !== null) { if (savingsRate !== null) {
this.savingsRateChanged.emit(savingsRate); this.savingsRateChanged.emit(savingsRate);
@ -172,7 +180,10 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy {
}); });
this.calculatorForm this.calculatorForm
.get('projectedTotalAmount') .get('projectedTotalAmount')
?.valueChanges.pipe(debounceTime(500), takeUntilDestroyed()) ?.valueChanges.pipe(
debounceTime(500),
takeUntilDestroyed(this.destroyRef)
)
.subscribe((projectedTotalAmount) => { .subscribe((projectedTotalAmount) => {
if (projectedTotalAmount !== null) { if (projectedTotalAmount !== null) {
this.projectedTotalAmountChanged.emit(projectedTotalAmount); this.projectedTotalAmountChanged.emit(projectedTotalAmount);
@ -180,7 +191,10 @@ export class GfFireCalculatorComponent implements OnChanges, OnDestroy {
}); });
this.calculatorForm this.calculatorForm
.get('retirementDate') .get('retirementDate')
?.valueChanges.pipe(debounceTime(500), takeUntilDestroyed()) ?.valueChanges.pipe(
debounceTime(500),
takeUntilDestroyed(this.destroyRef)
)
.subscribe((retirementDate) => { .subscribe((retirementDate) => {
if (retirementDate !== null) { if (retirementDate !== null) {
this.retirementDateChanged.emit(retirementDate); this.retirementDateChanged.emit(retirementDate);

Loading…
Cancel
Save