destroy socket event listener on component deactivate

Esse commit está contido em:
Alex Castillo
2016-05-13 15:54:48 -04:00
commit 17ef476a32
3 arquivos alterados com 15 adições e 3 exclusões
@@ -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);
}
}
+5 -1
Ver Arquivo
@@ -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);
}
}
+5 -1
Ver Arquivo
@@ -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);
}