import { Component, OnInit } from '@angular/core';
import { BeamStatsApiService } from "../main/services";

import { Observable } from 'rxjs/Observable';

import 'rxjs/add/observable/interval';
import 'rxjs/add/operator/publishReplay';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/startWith';

@Component({
    selector: 'beamstats-status',
    templateUrl: 'status.component.html',
    styleUrls: ['status.component.scss']
})
export class StatusComponent implements OnInit {

    public status$;
    constructor(private bstatsApi: BeamStatsApiService) {
    }

    ngOnInit() { 
        this.status$ = Observable.interval(20000).startWith(0)
            .mergeMap(() => this.bstatsApi.getStats())
            .do((res: {ingests: any[]}) => res.ingests = res.ingests.sort((a, b) => a['name'].localeCompare(b['name'])))
            .publishReplay(1)
            .refCount()
    }

}
import { Component, OnInit } from '@angular/core';
import { BeamStatsApiService } from "../main/services";

import 'rxjs/add/operator/publishReplay';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/do';


@Component({
    selector: 'beamstats-status',
    templateUrl: 'status.component.html',
    styleUrls: ['status.component.scss']
})
export class StatusComponent implements OnInit {

    public status$;
    constructor(private bstatsApi: BeamStatsApiService) {
    }

    ngOnInit() { 
        this.status$ = this.bstatsApi.getStats()
            .do((res: {ingests: any[]}) => res.ingests = res.ingests.sort((a, b) => a['name'].localeCompare(b['name'])))
            .publishReplay(1)
            .refCount()
    }

}
--- 
+++ 
@@ -1,11 +1,14 @@
 import { Component, OnInit } from '@angular/core';
 import { BeamStatsApiService } from "../main/services";
 
+import { Observable } from 'rxjs/Observable';
+
+import 'rxjs/add/observable/interval';
 import 'rxjs/add/operator/publishReplay';
 import 'rxjs/add/operator/mergeMap';
 import 'rxjs/add/operator/map';
 import 'rxjs/add/operator/do';
-
+import 'rxjs/add/operator/startWith';
 
 @Component({
     selector: 'beamstats-status',
@@ -19,7 +22,8 @@
     }
 
     ngOnInit() { 
-        this.status$ = this.bstatsApi.getStats()
+        this.status$ = Observable.interval(20000).startWith(0)
+            .mergeMap(() => this.bstatsApi.getStats())
             .do((res: {ingests: any[]}) => res.ingests = res.ingests.sort((a, b) => a['name'].localeCompare(b['name'])))
             .publishReplay(1)
             .refCount()
Set interval on Status updates
