How to implement polling using Observables?
See original GitHub issueI’ve got parametrized rest call with Observable interface:
api.updateAppState(params);
I want to repeat it with delay so I have created delayed version of it:
Observable<AppState> delayedApiCall = Observable.interval(delay, TimeUnit.SECONDS)
.first()
.flatMap(new Func1<Long, Observable<AppState>>() {
@Override
public Observable<AppState> call(Long seconds) {
return lyftApi.updateAppState(params);
}
});
But now I want to have polling observable that will recreate “delayedApiCall” with params and produce continuous results. I also want observable to continue producing results even if error was returned in “delayedApiCall”.
pollingObservable.subscribe(new Observer<AppState>() {
onNext(AppState appSte) {
....
},
onError(Throwable e) {
....
}
});
Issue Analytics
- State:
- Created 10 years ago
- Comments:20 (8 by maintainers)
Top Results From Across the Web
How to do polling with RxJs and Angular? | by Alain Chautard
In this tutorial, we're going to implement a polling mechanism using RxJs and Angular. Our goal is to retrieve and render information that ......
Read more >Http Polling - Learn RxJS
This recipe demonstrates one way you can achieve polling an HTTP endpoint on an ... import { Observable, Subscription, of, fromEvent, from, empty,...
Read more >Polling in Angular — How to use RxJS in Angular for polling?
In this component file, we are implementing the polling using RxJS. Here the interval is an Observable and is piped to execute the...
Read more >Polling using RxJS. As observables are gaining more and…
We will walk through an example of such a scenario and implement a solution using RxJS. On our way we will learn some...
Read more >Implement Polling Using RxJS in Your Angular Application
In this article, we will implement polling logic using RxJS. ... Create an observable that emits values on continuous intervals using the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Okay then, how about:
Use
Observable.interval()
as the starting point and forget that manual recursion.