如何修改以下代码,使得get请求“api/foobar”每500毫秒重复一次?
import {Observable} from "RxJS/Rx";
import {Injectable} from "@angular/core";
import {Http} from "@angular/http";
@Injectable() export class ExampleService {
constructor(private http: Http) { }
getFooBars(onNext: (fooBars: FooBar[]) => void) {
this.get("api/foobar")
.map(response => <FooBar[]>reponse.json())
.subscribe(onNext,
error =>
console.log("An error occurred when requesting api/foobar.", error));
}
}