fix(charts): unsubscribe when destroy component

This commit is contained in:
KostyaDanovsky 2017-09-20 14:11:22 +03:00
parent 08851fdfed
commit 549be765f0
19 changed files with 152 additions and 57 deletions

View file

@ -1,4 +1,4 @@
import { Component, AfterViewInit } from '@angular/core';
import { Component, AfterViewInit, OnDestroy } from '@angular/core';
import { NbThemeService } from '@nebular/theme';
@Component({
@ -7,14 +7,15 @@ import { NbThemeService } from '@nebular/theme';
<div echarts [options]="options" class="echart"></div>
`,
})
export class EchartsMultipleXaxisComponent implements AfterViewInit {
export class EchartsMultipleXaxisComponent implements AfterViewInit, OnDestroy {
options: any = {};
themeSubscription: any;
constructor(private theme: NbThemeService) {
}
ngAfterViewInit() {
this.theme.getJsTheme().subscribe(config => {
this.themeSubscription = this.theme.getJsTheme().subscribe(config => {
const colors: any = config.variables;
const echarts: any = config.variables.echarts;
@ -158,4 +159,8 @@ export class EchartsMultipleXaxisComponent implements AfterViewInit {
};
});
}
ngOnDestroy(): void {
this.themeSubscription.unsubscribe();
}
}