Created
May 10, 2017 13:28
-
-
Save p3x-robot/6ce267ba58ac3679e2836597e1fdd56a to your computer and use it in GitHub Desktop.
ObservableCreate.ts
This file contains hidden or 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
// 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