Created
October 2, 2016 17:45
-
-
Save winkerVSbecks/9e590fc6b7a15fa7b5f035de370cadae to your computer and use it in GitHub Desktop.
angular 2 observable polling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rx.Observable | |
.interval(500) | |
.flatMap(() => [1, 2, 3] /* in angular you will call getData() to make an HTTP request */) | |
.map(x => x + 1) | |
.subscribe(x => console.log(x)) | |
function getData() { | |
return this.http | |
.get('https://api.spotify.com/v1/search?q=' + term + '&type=artist') | |
.map((response) => response.json()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment