No "isCompleted" or "isErrored" methods on Observable
See original GitHub issueHey folks,
I was currently running into the situation where I just needed a quick check if my observable is already done (and in particular failed), but I wondered why this is not exposed on the Observable
- is there any specific reason?
my code was like
if (!observable.isCompleted()) {
rescheduleIt();
}
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
RxJS - observable doesn't complete when an error occurs
The statement will be always executed regardless an error occured or not (like the finally statement in most programming languages). observer.
Read more >My Fun with Angular Observables - TA Digital Labs
My lazy and strict friend is generous too, he does not mind if somebody wants to cancel the subscription through unsubscribe() method.
Read more >An intro to Observables and how they are different from ...
Observer.complete('completion of delivery of all values') // this tells the subscriptions to observable is completed. No delivery is going to ...
Read more >In Search of Better Loading and Error-handling in Angular
In this post, we'll experiment with various ways to handle loading and errors when fetching dynamic data. Our Starting Point. In my Use ......
Read more >RxJs Error Handling: Complete Practical Guide
Using this approach, we cannot, for example, recover from the error or ... If no error occurs, the output Observable produced by catchError ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
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
No results found
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
If you need this, your code is probably too imperative.
But more importantly, it makes no sense for cold observables like
Observable.range(1, 10)
because that is never completed.Assuming observable is hot, you can implement it yourself by doing
Note it is dangerous to rely on since there is a race condition
If an Observer/Subscriber receives and onCompleted or onError (or doesn’t want to any more onNext for any other reason) then it should unsubscribe from the Subscription. In a way isUnsubscribed on the Subscription/Subscriber can be used as a proxy for
isComplete() || isError()