onNext not called if onError is called immediately after when Scheduler is defined in observeOn
See original GitHub issueIf I set a Scheduler
in .observeOn(...)
for an Observable
and call subscriber.onError
immediately after subscriber.onNext
, onNext
is never called in my Observer
.
If I either add a sleep between subscriber.onNext
and subscriber.onError
or don’t set a Scheduler
in .observeOn(...)
, onNext
is called in my Observer
.
See example:
Observable.create(new Observable.OnSubscribe<String>() {
@Override
public void call(Subscriber<? super String> subscriber) {
subscriber.onNext("Test");
subscriber.onError(null);
}
}).observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<String>() {
@Override
public void onCompleted() {
System.out.println("onCompleted");
}
@Override
public void onError(Throwable e) {
System.out.println("onError");
}
@Override
public void onNext(String s) {
System.out.println("onNext");
}
});
// Only prints "onError", but should print "onNext" and then "onError"
Issue Analytics
- State:
- Created 8 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
RxJava Android onError takes too long to be called
RxJava Android onError takes too long to be called · Could you remove observeOn and use Schedulers.io() for subscribeOn and validate the result ......
Read more >ObserveOn operator - ReactiveX
Note that ObserveOn will forward an onError termination notification immediately if it receives one, and will not wait for a slow-consuming observer to ......
Read more >Understanding RxJava subscribeOn and observeOn
This scheduler is expensive as new thread is spawned every time and no reuse happens. Schedulers.from(Executor executor) creates and returns a ...
Read more >Exploring RxJava in Android
On the other hand, calling the method observeOn , will set up the thread ... By default, if no such Scheduler is provided,...
Read more >Fundamentals of RxJava with Kotlin for absolute beginners
Let's break it down, just converts the string "Hello Reactive World" to an ... onNext(kind) ... If there's no value, onError will be...
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
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
Note to future self because I know I’m going to forget this (again): you can use
.observeOn(Scheduler scheduler, boolean delayError)
to ensure onNext isn’t skipped by onError.Something like this: