Questions tagged [rx-java]

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

RxJava is a Java implementation of Reactive Extensions. Android-specific support for RxJava is provided by .

The main goals of RxJava

  • Stay true to the principles and concepts behind the original implementation while adjusting to the naming conventions and idioms of Java
  • All contracts of Rx should be the same target - the JVM
  • JVM-based languages supported (beyond Java itself) include , , , and
  • Support Java 6+

The library is open sourced under Apache 2.0 license.

References

6958 questions
23
votes
1 answer

Process Observable on background thread

I am using RxAndroid for stream operations. In my real use-case, i am fetching a list from the server (using Retrofit). I am using schedulers to do the work on a background thread and get the final emission on the Android UI (main) thread. This…
WonderCsabo
  • 11,947
  • 13
  • 63
  • 105
23
votes
2 answers

Rxjava and Volley Requests

My question should sounds something like stupid, but i am just jumping from Asynktask to RxJava. So: Is possible to use RxJava Observable with Volley Requests?, it means, using future requests. I ask this, because another httpClient like retrofit…
Max Pinto
  • 1,463
  • 3
  • 16
  • 29
23
votes
5 answers

Rx Observable emitting values periodically

I have to poll some RESTful endpoint periodically to refresh my android app's data. I also have to pause and resume it based on connectivity (if the phone is offline, there's no need to even try). My current solution is working, but it uses standard…
Haspemulator
  • 11,050
  • 9
  • 49
  • 76
22
votes
1 answer

The mapper function returned a null value

I set same build types for debug and release, buildTypes { debug { buildConfigField "String", "API_BASE_URL", "\"https://www.testUrl.com/api/\"" minifyEnabled true shrinkResources true proguardFiles…
Expert wanna be
  • 10,218
  • 26
  • 105
  • 158
22
votes
2 answers

RxJava Scheduler to observe on main thread

If I write something like this, then both the operation and notification will be on the current thread... Observable.fromCallable(() -> "Do Something") .subscribe(System.out::println); If I do the operation on a background thread like this,…
Eurig Jones
  • 8,226
  • 7
  • 52
  • 74
22
votes
3 answers

Difference between vert.x and RxJava

We are evaluating reactive programming frameworks for one of our projects. I just went through vert.x tutorials. I checked RxJava presentation a bit. RxJava seemed more close to CompletableFuture. But despite the underlying patterns, both RxJava and…
user3276247
  • 1,046
  • 2
  • 9
  • 24
22
votes
4 answers

RxJava 2 overriding IO scheduler in unit test

I'm trying to test the following RxKotlin/RxJava 2 code: validate(data) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .flatMap { ... } I'm attempting to override the schedulers as follows: // Runs before each…
Alex
  • 739
  • 1
  • 6
  • 18
22
votes
6 answers

Unit testing android application with retrofit and rxjava

I have developed an android app that is using retrofit with rxJava, and now I'm trying to set up the unit tests with Mockito but I don't know how to mock the api responses in order to create tests that do not do the real calls but have fake…
FVod
  • 2,245
  • 5
  • 25
  • 52
22
votes
3 answers

Differences between RxJava1 and RxJava2

I've been looking the documentations of RxJava1 https://github.com/ReactiveX/RxJava/releases and RxJava2 https://github.com/ReactiveX/RxJava/wiki/Reactive-Streams and seems like the unique different is that RxJava 2 has Java Stream. Any other…
paul
  • 12,873
  • 23
  • 91
  • 153
22
votes
4 answers

Using RxJava and Okhttp

I want to request to a url using okhttp in another thread (like IO thread) and get Response in the Android main thread, But I don't know how to create an Observable.
user5357773
22
votes
5 answers

AndroidRX - run method in background

I created simple activity with infinity progres bar, and I'am trying to run time consuming method using RxJava to prevent UI thread from blocking, but everytime UI thread is blocked. I think my solution has problem with emitting Observable. Can…
panbacuh
  • 622
  • 1
  • 9
  • 17
22
votes
1 answer

RxJava + Retrofit polling

My problem is i can't get infinite stream with Retrofit. After i get credentials for initial poll() request - i do initial poll() request. Each poll() request responds in 25 sec if there is no change, or earlier if there are any changes - returning…
localhost
  • 5,568
  • 1
  • 33
  • 53
21
votes
7 answers

How to pass null to an Observable with nullable type in RxJava 2 and Kotlin

I initialize my variable like this:- val user: BehaviorSubject user = BehaviorSubject.create() But I can't do this. IDE throws an error:- user.onNext(null) And doing this, IDE says u will never be null:- user.filter( u -> u!=null)
Abhinav Nair
  • 958
  • 1
  • 8
  • 29
21
votes
4 answers

Immediate debounce in Rx

I am looking an operator to debounce a series of event, let us say user's click. The input and output should be like this: interval : -> <- -> <- in : 1--2--3-------4--5--5--6-7-8-------- out :…
Quang Linh Le
  • 751
  • 1
  • 7
  • 16
21
votes
2 answers

RxJava, one observable multiple subscribers: publish().autoConnect()

I'm playing around with rxJava/rxAndroid and there's something very basic that doesn't behave as I'd expect. I have this one observable and two subscribers: Observable dataStream = Observable.just(1, 2,…
frankelot
  • 13,666
  • 16
  • 54
  • 89