Browse Source

Eliminate OnDestroy hook

pull/6673/head
Erwin-N 2 months ago
parent
commit
863790da4d
  1. 25
      libs/ui/src/lib/assistant/assistant.component.ts

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

@ -11,17 +11,18 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
DestroyRef,
ElementRef,
HostListener,
Input,
OnChanges,
OnDestroy,
OnInit,
QueryList,
ViewChild,
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 +41,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 +49,6 @@ import {
map,
scan,
switchMap,
takeUntil,
tap
} from 'rxjs/operators';
@ -84,7 +84,7 @@ import {
styleUrls: ['./assistant.scss'],
templateUrl: './assistant.html'
})
export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
export class GfAssistantComponent implements OnChanges, OnInit {
public static readonly SEARCH_RESULTS_DEFAULT_LIMIT = 5;
@Input() deviceType: string;
@ -146,12 +146,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 +333,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
)
);
}),
takeUntil(this.unsubscribeSubject)
takeUntilDestroyed(this.destroyRef)
)
.subscribe({
next: (searchResults) => {
@ -477,7 +477,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 +556,6 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
if (this.preselectionTimeout) {
clearTimeout(this.preselectionTimeout);
}
this.unsubscribeSubject.next();
this.unsubscribeSubject.complete();
}
private getCurrentAssistantListItem() {
@ -643,7 +640,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
};
});
}),
takeUntil(this.unsubscribeSubject)
takeUntilDestroyed(this.destroyRef)
);
}
@ -678,7 +675,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
}
);
}),
takeUntil(this.unsubscribeSubject)
takeUntilDestroyed(this.destroyRef)
);
}
@ -710,7 +707,7 @@ export class GfAssistantComponent implements OnChanges, OnDestroy, OnInit {
}
);
}),
takeUntil(this.unsubscribeSubject)
takeUntilDestroyed(this.destroyRef)
);
}

Loading…
Cancel
Save