Browse Source

Task/eliminate OnDestroy lifecycle hook from assistant component (#6673)

Eliminate OnDestroy lifecycle hook
pull/6721/head
Erwin 3 days ago
committed by GitHub
parent
commit
5afceb802c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 22
      libs/ui/src/lib/assistant/assistant.component.ts

22
libs/ui/src/lib/assistant/assistant.component.ts

@ -11,6 +11,7 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
DestroyRef,
ElementRef,
HostListener,
Input,
@ -22,6 +23,7 @@ import {
ViewChildren,
output
} from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatFormFieldModule } from '@angular/material/form-field';
@ -40,7 +42,7 @@ import {
} from 'ionicons/icons';
import { isFunction } from 'lodash';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { EMPTY, Observable, Subject, merge, of } from 'rxjs';
import { EMPTY, Observable, merge, of } from 'rxjs';
import {
catchError,
debounceTime,
@ -48,7 +50,6 @@ import {
map,
scan,
switchMap,
takeUntil,
tap
} from 'rxjs/operators';
@ -146,12 +147,12 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
private keyManager: FocusKeyManager<GfAssistantListItemComponent>;
private preselectionTimeout: ReturnType<typeof setTimeout>;
private unsubscribeSubject = new Subject<void>();
public constructor(
private adminService: AdminService,
private changeDetectorRef: ChangeDetectorRef,
private dataService: DataService
private dataService: DataService,
private destroyRef: DestroyRef
) {
addIcons({ closeCircleOutline, closeOutline, searchOutline });
}
@ -333,7 +334,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
)
);
}),
takeUntil(this.unsubscribeSubject)
takeUntilDestroyed(this.destroyRef)
)
.subscribe({
next: (searchResults) => {
@ -477,7 +478,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
this.dataService
.fetchPortfolioHoldings()
.pipe(takeUntil(this.unsubscribeSubject))
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe(({ holdings }) => {
this.holdings = holdings
.filter(({ assetSubClass }) => {
@ -556,9 +557,6 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
if (this.preselectionTimeout) {
clearTimeout(this.preselectionTimeout);
}
this.unsubscribeSubject.next();
this.unsubscribeSubject.complete();
}
private getCurrentAssistantListItem() {
@ -643,7 +641,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
};
});
}),
takeUntil(this.unsubscribeSubject)
takeUntilDestroyed(this.destroyRef)
);
}
@ -678,7 +676,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
}
);
}),
takeUntil(this.unsubscribeSubject)
takeUntilDestroyed(this.destroyRef)
);
}
@ -710,7 +708,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
}
);
}),
takeUntil(this.unsubscribeSubject)
takeUntilDestroyed(this.destroyRef)
);
}

Loading…
Cancel
Save