mirror of
https://github.com/akveo/ngx-admin.git
synced 2026-02-11 19:04:20 +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,7 +6,7 @@ import { NbThemeService } from '@nebular/theme';
|
|||
styleUrls: ['./temperature.component.scss'],
|
||||
templateUrl: './temperature.component.html',
|
||||
})
|
||||
export class TemperatureComponent {
|
||||
export class TemperatureComponent implements OnDestroy {
|
||||
|
||||
temperature: number = 24;
|
||||
temperatureOff: boolean = false;
|
||||
|
|
@ -17,10 +17,15 @@ export class TemperatureComponent {
|
|||
humidityMode = 'heat';
|
||||
|
||||
colors: any;
|
||||
themeSubscription: any;
|
||||
|
||||
constructor(private theme: NbThemeService) {
|
||||
this.theme.getJsTheme().subscribe(config => {
|
||||
this.themeSubscription = this.theme.getJsTheme().subscribe(config => {
|
||||
this.colors = config.variables;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.themeSubscription.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue