Wie man einen http-Aufruf alle 2 Minuten mit RXJS?

Habe ich einen service zu machen, dass ein Anruf auf mein rest-service alle 2 Minuten. Auf meinem service ich habe die folgende Funktion

  getNotifications(token: string) {
     const body = 'xxxxxxxxx=' + token;
     return this.http.post('/rest/ssss/ddddddd/notificationcount', body, this.options)
          .map((res) => res.json());
  }

Auf meine Komponente nenne ich auch mein service-Funktion zum Aufruf der API.

this.notificationService.getNotifications(this.token).subscribe((data) => {
  console.log(data);
});

Möchte ich diesen Aufruf alle 2 Minuten, was ist der beste Weg, dies zu tun?

  • Hat man sich bei repeatWhen?
InformationsquelleAutor Ennio | 2017-06-28
Schreibe einen Kommentar