Skip to content

Instantly share code, notes, and snippets.

@p3x-robot
Created May 10, 2017 13:28
Show Gist options
  • Save p3x-robot/6ce267ba58ac3679e2836597e1fdd56a to your computer and use it in GitHub Desktop.
Save p3x-robot/6ce267ba58ac3679e2836597e1fdd56a to your computer and use it in GitHub Desktop.
ObservableCreate.ts
// http://stackoverflow.com/questions/42884746/reactivex-observable-to-trigger-when-i-want-to/42902431#42902431
const obs = Observable.create(async (obs : any ) => {
const newInfo = async () => {
return this.http.get(`http://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&cache=${new Date().getTime()}`).toPromise();
}
obs.next(await newInfo());
setInterval(async () => {
obs.next(await newInfo());
console.log('update');
}, 10000)
})
obs.subscribe((response : any) => {
console.log(response.json()[0].content);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment