What’s the point of .switchIfEmpty() getting evaluated eagerly?

What you need to understand here is the difference between assembly time and subscription time. Assembly time is when you create your pipeline by building the operator chain. At this point your publisher is not subscribed yet and you need to think kind of imperatively. Subscription time is when you trigger the execution by subscribing … Read more

Do small Calculation Task in Background Using RxJava in Most Efficient Way

If you want to use RxJava you get to leverage non-blocking by composing multiple operations in Observables. There are plenty of tutorials out there to help. To answer your question though using RxJava 1: Completable .fromRunnable(() -> doSomething()) .doOnError(e -> log.error(e.getMessage(), e)) .subscribeOn(Schedulers.computation()) .subscribe(); If doSomething doesn’t use CPU exclusively then you might choose Schedulers.io() … Read more