mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-16 07:30:12 +01:00
refactor(header): use takeUntil to unsubscribe
And remove commented lines and unnecessary imports.
This commit is contained in:
parent
c643a46b50
commit
a381ac2524
1 changed files with 12 additions and 12 deletions
|
|
@ -4,11 +4,11 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*/
|
||||
|
||||
import { Component, HostBinding, Input, OnDestroy } from '@angular/core';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
import { OnInit, Component, HostBinding, Input, OnDestroy } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
import { NbSidebarService } from '@nebular/theme';
|
||||
|
||||
/*import { NgxAnalytics } from '../../services/analytics.service';*/
|
||||
import { NgxVersionService } from '../../services/version.service';
|
||||
import { HeaderMenuService } from '../../../@core/data/service/header-menu.service';
|
||||
|
||||
|
|
@ -17,9 +17,9 @@ import { HeaderMenuService } from '../../../@core/data/service/header-menu.servi
|
|||
styleUrls: ['./header.component.scss'],
|
||||
templateUrl: './header.component.html',
|
||||
})
|
||||
export class NgxLandingHeaderComponent implements OnDestroy {
|
||||
export class NgxLandingHeaderComponent implements OnInit, OnDestroy {
|
||||
|
||||
private alive = true;
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
@HostBinding('class.docs-page') @Input() isDocs = false;
|
||||
|
||||
|
|
@ -28,25 +28,25 @@ export class NgxLandingHeaderComponent implements OnDestroy {
|
|||
currentVersion: string;
|
||||
headerMenu = [];
|
||||
|
||||
constructor(/*private analytics: NgxAnalytics,*/
|
||||
private sidebarService: NbSidebarService,
|
||||
constructor(private sidebarService: NbSidebarService,
|
||||
private versionService: NgxVersionService,
|
||||
private headerMenuService: HeaderMenuService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.currentVersion = this.versionService.getNgxVersion();
|
||||
|
||||
this.headerMenuService.getHeaderMenu()
|
||||
.pipe(takeWhile(() => this.alive ))
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((headerMenu) => this.headerMenu = headerMenu);
|
||||
}
|
||||
|
||||
trackEmailClick() {
|
||||
}
|
||||
|
||||
toggleSidebar() {
|
||||
this.sidebarService.toggle(false, this.sidebarTag);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.alive = false;
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue