angular 2 Implement rxjs - IntervalObservable for

2019-07-29 17:22发布

问题:

I want make a HTTP request and dynamically update in the UI the value that's being observed!

import { IntervalObservable } from 'rxjs/observable/IntervalObservable'; 

@Component({ ... }) export class AppComponent { 
    n: number = 0;
     constructor() { 
        IntervalObservable.create(1000).subscribe(n => this.n = n); 
     } 
}

Is there a better way to do this?