destroy socket event listener on component deactivate
Esse commit está contido em:
@@ -1,4 +1,4 @@
|
||||
import { Component, ElementRef, OnInit, Input } from '@angular/core';
|
||||
import { Component, ElementRef, OnInit, OnDestroy, Input } from '@angular/core';
|
||||
import * as io from 'socket.io-client';
|
||||
import { ChartService } from '../shared';
|
||||
import { CHART_DIRECTIVES } from '../shared/ng2-charts';
|
||||
@@ -40,5 +40,9 @@ export class FrequencyBandComponent implements OnInit {
|
||||
this.data = data[this.band || 'data'];
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
this.socket.removeListener(this.constants.socket.events.fft);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, ElementRef, OnInit, Input } from '@angular/core';
|
||||
import { Component, ElementRef, OnInit, OnDestroy, Input } from '@angular/core';
|
||||
import { RouteSegment, ROUTER_PROVIDERS } from '@angular/router';
|
||||
import * as io from 'socket.io-client';
|
||||
import { ChartService } from '../shared';
|
||||
@@ -40,5 +40,9 @@ export class FrequencyComponent implements OnInit {
|
||||
this.labels = data.labels;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
this.socket.removeListener(this.constants.socket.events.fft);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, ElementRef, OnInit } from '@angular/core';
|
||||
import { Component, ElementRef, OnInit, OnDestroy } from '@angular/core';
|
||||
import { SmoothieChart, TimeSeries } from 'smoothie';
|
||||
import { ChartService } from '../shared';
|
||||
import * as io from 'socket.io-client';
|
||||
@@ -42,6 +42,10 @@ export class TimeSeriesComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
this.socket.removeListener(this.constants.socket.events.time);
|
||||
}
|
||||
|
||||
ngAfterViewInit () {
|
||||
this.timeSeries.streamTo(this.view.nativeElement.querySelector('canvas'), 40);
|
||||
}
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário