How to make HTTP request at an interval?
<p>I am quite new to angular and rxjs. 
I am trying to create an angular2 app that gets some data from staticly served text file(Locally on server), which I would like to retrieve and map to Datamodel using Angular2's http provider and rxjs's map at a fixed time <code>interval(5000)</code>. To reflect any changes to the served txt file. </p>

<p>With rxjs 4.x I know you could use <code>Observable.interval(5000)</code> to do the job, but it does not seem to exist in rxjs 5. 
My workaround currently refresh the whole application using <code>&lt;meta http-equiv="refresh" content="5" &gt;</code> Which reloads the whole page, and thus reloads the data.</p>

<p>So what I would really like is some way to do this working with observables, maybe to check if any changes have happened. or just to reload the data anew.</p>

<p>Any help or other/better way will be very much appreciated.</p>

<p>What I have so far:</p>

<pre><code>@Injectable()
export class DataService {

    constructor(private http:Http){}

    getData(url) {
        return this.http.get(url)
            .map(res =&gt; {
                return res.text();
            })
            .map(res =&gt; {
                return res.split("\n");
            })
            .map(res =&gt; {
                var dataModels: DataModel[] = [];
                res.forEach(str =&gt; {
                    var s = str.split(",");
                    if(s[0] !== "") {
                        dataModels.push(new DataModel(s[0], parseInt(s[1]), parseInt(s[2])));
                    }
                });
                return dataModels;
            })
    }
}

@Component({
selector: 'my-app',
template: `Some html to display the data`,
providers: [DataService],
export class AppComponent {

data:DataModel[];

constructor(dataService:DataService) {}

ngOnInit() {
    this.dataService.getData('url').subscribe(
        res =&gt; {
            this.data= res;

        },
        err =&gt; console.log(err),
        () =&gt; console.log("Data received")
        );
    }
}
</code></pre>

<p>Dependencies: package.json</p>

<pre><code>"dependencies": {
  "angular2": "^2.0.0-beta.3",
  "bootstrap": "^4.0.0-alpha.2",
  "es6-promise": "^3.0.2",
  "es6-shim": "^0.33.13",
  "jquery": "^2.2.0",
  "reflect-metadata": "^0.1.2",
  "rxjs": "^5.0.0-beta.0",
  "systemjs": "^0.19.20",
  "zone.js": "^0.5.11"
},
"devDependencies": {
  "typescript": "^1.7.5"
}
</code></pre>

<p>index.html imports: </p>

<pre><code>&lt;script src="node_modules/es6-shim/es6-shim.min.js"&gt;&lt;/script&gt;
&lt;script src="node_modules/systemjs/dist/system-polyfills.js"&gt;&lt;/script&gt;

&lt;script src="node_modules/angular2/bundles/angular2-polyfills.js"&gt;&lt;/script&gt;
&lt;script src="node_modules/systemjs/dist/system.src.js"&gt;&lt;/script&gt;
&lt;script src="node_modules/rxjs/bundles/Rx.js"&gt;&lt;/script&gt;
&lt;script src="node_modules/angular2/bundles/angular2.dev.js"&gt;&lt;/script&gt;
&lt;script src="node_modules/angular2/bundles/router.dev.js"&gt;&lt;/script&gt;
&lt;script src="node_modules/angular2/bundles/http.dev.js"&gt;&lt;/script&gt;
</code></pre>