mirror of
https://github.com/akveo/ngx-admin.git
synced 2026-01-25 02:36:10 +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({
|
||||
|
|
@ -13,7 +13,7 @@ import { NbThemeService } from '@nebular/theme';
|
|||
</nb-card>
|
||||
`,
|
||||
})
|
||||
export class BubbleMapComponent {
|
||||
export class BubbleMapComponent implements OnDestroy {
|
||||
|
||||
latlong: any = {};
|
||||
mapData: any[];
|
||||
|
|
@ -23,10 +23,11 @@ export class BubbleMapComponent {
|
|||
|
||||
bubbleTheme: any;
|
||||
geoColors: any[];
|
||||
themeSubscription: any;
|
||||
|
||||
constructor(private theme: NbThemeService) {
|
||||
|
||||
this.theme.getJsTheme()
|
||||
this.themeSubscription = this.theme.getJsTheme()
|
||||
.subscribe(config => {
|
||||
|
||||
const colors = config.variables;
|
||||
|
|
@ -525,6 +526,10 @@ export class BubbleMapComponent {
|
|||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.themeSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
private getRandomGeoColor() {
|
||||
const index = Math.round(Math.random() * this.geoColors.length);
|
||||
return this.geoColors[index];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue