mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-20 17:30:14 +01:00
refactor(demo): unsubscribe when destroy component
This commit is contained in:
parent
549be765f0
commit
cceabef8eb
12 changed files with 96 additions and 37 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { NbThemeService } from '@nebular/theme';
|
||||
|
||||
@Component({
|
||||
|
|
@ -6,13 +6,14 @@ import { NbThemeService } from '@nebular/theme';
|
|||
styleUrls: ['./hero-buttons.component.scss'],
|
||||
templateUrl: './hero-buttons.component.html',
|
||||
})
|
||||
export class HeroButtonComponent {
|
||||
export class HeroButtonComponent implements OnDestroy {
|
||||
|
||||
themeName: string = 'default';
|
||||
settings: Array<any>;
|
||||
themeSubscription: any;
|
||||
|
||||
constructor(private themeService: NbThemeService) {
|
||||
this.themeService.getJsTheme().subscribe(theme => {
|
||||
this.themeSubscription = this.themeService.getJsTheme().subscribe(theme => {
|
||||
this.themeName = theme.name;
|
||||
this.init(theme.variables);
|
||||
});
|
||||
|
|
@ -115,4 +116,8 @@ export class HeroButtonComponent {
|
|||
},
|
||||
}];
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.themeSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue