Skip to content

Instantly share code, notes, and snippets.

@winkerVSbecks
Created October 2, 2016 17:45
Show Gist options
  • Save winkerVSbecks/9e590fc6b7a15fa7b5f035de370cadae to your computer and use it in GitHub Desktop.
Save winkerVSbecks/9e590fc6b7a15fa7b5f035de370cadae to your computer and use it in GitHub Desktop.
angular 2 observable polling
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