2.x: Single.flatMapObservable does not respect observeOn
See original GitHub issueRxJava version 2.1.2.
The following code:
Single.just("Test")
.subscribeOn(Schedulers.computation())
.flatMapObservable(
s -> {
System.out.println("1: " + Thread.currentThread());
return Observable.just(1)
.observeOn(Schedulers.io())
//.doOnNext(o -> System.out.println("2: " + Thread.currentThread()))
;
}
)
.subscribe(o -> {
System.out.println("3: " + Thread.currentThread());
});
…produces the following output:
1: Thread[RxComputationThreadPool-1,5,main]
3: Thread[RxComputationThreadPool-1,5,main]
Expected output here is:
1: Thread[RxComputationThreadPool-1,5,main]
3: Thread[RxCachedThreadScheduler-1,5,main]
However, when the line containing doOnNext
is uncommented, this is the output:
1: Thread[RxComputationThreadPool-1,5,main]
2: Thread[RxCachedThreadScheduler-1,5,main]
3: Thread[RxCachedThreadScheduler-1,5,main]
It looks like the thread is not switched in the first case.
Issue Analytics
- State:
- Created 6 years ago
- Comments:20 (18 by maintainers)
Top Results From Across the Web
Single (RxJava Javadoc 2.2.13)
Like Observable , a running Single can be stopped through the Disposable instance provided to consumers through SingleObserver.onSubscribe(io.reactivex.
Read more >Single (RxJava Javadoc 3.1.5) - ReactiveX
The Single class implements the Reactive Pattern for a single value response. Single behaves similarly to Observable except that it can only emit...
Read more >Understanding RxJava subscribeOn and observeOn
flatMap() wraps each item being emitted by an Observable letting you apply its own RxJava operators including assigning a new Scheduler using ...
Read more >Why doesn't my RxJava Flowable respect backpressure when ...
You don't need it because Flowable.fromIterable (and by the way, RxJava has a range operator) supports and honors backpressure.
Read more >目录 - Gitee
How does this relate to RxJava itself? RxJava 1.x. RxJava 2.x. Public APIs of Libraries. Pros of Exposing Reactive Stream APIs instead of...
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
If you bind data, delaying a frame will cause a noticeable UI problem.
That’s why peoply, by reflex, apply
.observeOn(AndroidSchedulers.mainThread())
to route the results back to the main thread.