Fix memory leak and refresh timer
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+5
-5
@@ -221,10 +221,14 @@ var DetailComponent = (function () {
|
||||
var _this = this;
|
||||
this.id = this.route.snapshot.params['id'];
|
||||
this.refreshData(this.id);
|
||||
__WEBPACK_IMPORTED_MODULE_2_rxjs_observable_IntervalObservable__["IntervalObservable"].create(1000).subscribe(function (n) { return _this.refreshData(_this.id); });
|
||||
this.subscription = __WEBPACK_IMPORTED_MODULE_2_rxjs_observable_IntervalObservable__["IntervalObservable"].create(7500).subscribe(function (n) { return _this.refreshData(_this.id); });
|
||||
};
|
||||
DetailComponent.prototype.ngOnDestroy = function () {
|
||||
this.subscription.unsubscribe();
|
||||
};
|
||||
DetailComponent.prototype.refreshData = function (id) {
|
||||
var _this = this;
|
||||
console.log("Refreshing data for ", this.id);
|
||||
this.dataService
|
||||
.get(id)
|
||||
.subscribe(function (res) {
|
||||
@@ -236,8 +240,6 @@ var DetailComponent = (function () {
|
||||
this.dataService
|
||||
.usage(id)
|
||||
.subscribe(function (res) {
|
||||
console.log("Usage:");
|
||||
console.log(res);
|
||||
_this.hov = res.hov;
|
||||
_this.htv = res.htv;
|
||||
_this.ht = res.ht;
|
||||
@@ -245,8 +247,6 @@ var DetailComponent = (function () {
|
||||
this.dataService
|
||||
.name(id)
|
||||
.subscribe(function (res) {
|
||||
console.log("Name:");
|
||||
console.log(res);
|
||||
_this.name = res;
|
||||
});
|
||||
};
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,7 +1,8 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
|
||||
import { IntervalObservable } from 'rxjs/observable/IntervalObservable';
|
||||
import { Subscription } from 'rxjs/Subscription';
|
||||
|
||||
import { DataService } from './data.service';
|
||||
import {LineChartComponent} from "./chart.component";
|
||||
@@ -29,6 +30,8 @@ export class DetailComponent implements OnInit {
|
||||
|
||||
public loaded:boolean = false;
|
||||
|
||||
public subscription:Subscription;
|
||||
|
||||
constructor(private dataService: DataService,
|
||||
private route: ActivatedRoute) {}
|
||||
|
||||
@@ -38,12 +41,18 @@ export class DetailComponent implements OnInit {
|
||||
|
||||
this.refreshData(this.id);
|
||||
|
||||
IntervalObservable.create(1000).subscribe(n => this.refreshData(this.id));
|
||||
this.subscription = IntervalObservable.create(7500).subscribe(n => this.refreshData(this.id));
|
||||
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
|
||||
refreshData(id:string)
|
||||
{
|
||||
console.log("Refreshing data for ", this.id);
|
||||
|
||||
this.dataService
|
||||
.get(id)
|
||||
.subscribe(res => {
|
||||
@@ -60,9 +69,6 @@ export class DetailComponent implements OnInit {
|
||||
.usage(id)
|
||||
.subscribe(res => {
|
||||
|
||||
console.log("Usage:");
|
||||
console.log(res);
|
||||
|
||||
this.hov = res.hov;
|
||||
this.htv = res.htv;
|
||||
this.ht = res.ht;
|
||||
@@ -73,9 +79,6 @@ export class DetailComponent implements OnInit {
|
||||
.name(id)
|
||||
.subscribe(res => {
|
||||
|
||||
console.log("Name:");
|
||||
console.log(res);
|
||||
|
||||
this.name = res;
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user