Questions tagged [rx-java2]

anything related to RxJava2 – The new implementation of the RxJava Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.

RxJava2 is the new implementation of the RxJava Reactive Extensions for the JVM – RxJava2 is a library for composing asynchronous and event-based programs using observable sequences for the Java VM.

It extends the observer pattern to support sequences of data/events and adds operators that allow you to compose sequences together declaratively while abstracting away concerns about things like low-level threading, synchronization, thread-safety and concurrent data structures.

4140 questions
229
votes
11 answers

When to use RxJava in Android and when to use LiveData from Android Architectural Components?

I am not getting the reason to use RxJava in Android and LiveData from Android Architectural Components.It would be really helpful if the usecases and differences between the both are explained along with sample example in the form of code which…
157
votes
8 answers

The result of subscribe is not used

I've upgraded to Android Studio 3.1 today, which seems to have added a few more lint checks. One of these lint checks is for one-shot RxJava2 subscribe() calls that are not stored in a variable. For example, getting a list of all players from my…
Michael Dodd
  • 10,102
  • 12
  • 51
  • 64
140
votes
3 answers

What is the difference between Observable, Completable and Single in RxJava

Can anyone please explain the difference between Observable, Completable and Single in RxJava with clear examples? In which scenario we use one over the others?
Raja Jawahar
  • 6,742
  • 9
  • 45
  • 56
112
votes
4 answers

Unable to create call adapter for io.reactivex.Observable

I'm going to send a simple get method to my server(it is Rails app) and get the result using RxJava and Retrofit. The thing that I did is: My interface: public interface ApiCall { String SERVICE_ENDPOINT = "https://198.50.214.15"; …
Hussein Ojaghi
  • 2,260
  • 3
  • 23
  • 41
104
votes
6 answers

Rxandroid What's the difference between SubscribeOn and ObserveOn

I am just learning Rx-java and Rxandroid2 and I am just confused what is the major difference between in SubscribeOn and ObserveOn.
Rathore
  • 1,926
  • 3
  • 19
  • 29
83
votes
5 answers

How to chain two Completable in RxJava2

I have two Completable. I would like to do following scenario: If first Completable gets to onComplete , continue with second Completable. The final results would be onComplete of second Completable. This is how I do it when I have Single…
Mladen Rakonjac
  • 9,562
  • 7
  • 42
  • 55
81
votes
9 answers

Cannot resolve symbol InstantTaskExecutorRule

I open example code BasicRxJavaSample (from this article Room+RxJava) The main thing is there: @Rule public InstantTaskExecutorRule instantTaskExecutorRule = new InstantTaskExecutorRule(); And BasicRxJavaSample is all ok. But I can not apply…
tim4dev
  • 2,846
  • 2
  • 24
  • 30
80
votes
3 answers

How to use CompositeDisposable of RxJava 2?

In RxJava 1, there was CompositeSubscription, but that is not present in RxJava2, There is something CompositeDisposable in rxJava2. How do I use CompositeDisposable or Disposable in RxJava2?
anand gaurav
  • 915
  • 2
  • 7
  • 9
73
votes
10 answers

Android RxJava 2 JUnit test - getMainLooper in android.os.Looper not mocked RuntimeException

I am encountering a RuntimeException when attempting to run JUnit tests for a presenter that is using observeOn(AndroidSchedulers.mainThread()). Since they are pure JUnit tests and not Android instrumentation tests, they don't have access to…
starkej2
  • 11,391
  • 6
  • 35
  • 41
72
votes
4 answers

Difference between RxJava API and the Java 9 Flow API

It seems on every iteration of Java for the last few major releases, there are consistently new ways to manage concurrent tasks. In Java 9, we have the Flow API which resembles the Flowable API of RxJava but with Java 9 has a much simpler set of…
Dovmo
  • 8,121
  • 3
  • 30
  • 44
65
votes
4 answers

When to call dispose and clear on CompositeDisposable

My question can be a duplicate of How to use CompositeDisposable of RxJava 2? But asking to clear one more doubt. According to the accepted answer // Using clear will clear all, but can accept new disposable disposables.clear(); // Using dispose…
user4260260
52
votes
1 answer

Subscribewith Vs subscribe in RxJava2(Android)?

When to call the subscribeWith method rather than plain subscribe? And what is the use case? compositeDisposable.add(get() .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(this::handleResponse,…
bastami82
  • 5,955
  • 7
  • 33
  • 44
50
votes
6 answers

Reactive Programming Advantages/Disadvantages

I keep studying and trying Reactive Style of coding using Reactor and RxJava. I do understand that reactive coding makes better utilization of CPU compared to single threaded execution. Is there any concrete comparison between reactive programming…
prranay
  • 1,789
  • 5
  • 23
  • 33
43
votes
4 answers

RxJava2 observable take throws UndeliverableException

As I understand RxJava2 values.take(1) creates another Observable that contains only one element from the original Observable. Which MUST NOT throw an exception as it is filtered out by the effect of take(1) as it's happened second. as in the…
abd3lraouf
  • 1,438
  • 1
  • 18
  • 24
42
votes
6 answers

RxJava 2.x: Should I use Flowable or Single/Completable?

I'm developing an Android app using Clean Architecture and I'm migrating it to RxJava 2.x. I have to make some network requests to a soap service, so I defined the api interface in the domain module: public interface SiginterApi { …
1
2 3
99 100