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
21
votes
1 answer

RxJava- performing a peek() or void operation within an Observable chain?

Java 8 lambda streams have a peek() operator which allows you to execute a void operation on each item. This is typically used for debugging, but it also is a nice way to cheat and kick off a void operation without mapping to something. Is there…
tmn
  • 11,121
  • 15
  • 56
  • 112
21
votes
2 answers

How to compose Observables to avoid the given nested and dependent callbacks?

In this blog, he gives this (copy/pasted the following code) example for the callback hell. However, there is no mention of how the issue can be eliminated by using Reactive Extensions. So here F3 depends upon F1 completion and F4 and F5 depend…
Aravind Yarram
  • 78,777
  • 46
  • 231
  • 327
21
votes
3 answers

RxJava and Cached Data

I'm still fairly new to RxJava and I'm using it in an Android application. I've read a metric ton on the subject but still feel like I'm missing something. I have the following scenario: I have data stored in the system which is accessed via…
Donn Felker
  • 9,553
  • 7
  • 48
  • 66
21
votes
2 answers

Getting Header information with RXJava and Retrofit

I'm trying to convert my app which currently uses Retrofit, to use RX Java. In order to handle Pagination, I traditionally was grabbing the nextPage URL from the response headers. @Override public void success(Assignment assignment, Response…
user3169791
  • 351
  • 2
  • 3
  • 9
21
votes
2 answers

retrofit with rxjava handling network exceptions globally

I am trying to handle exceptions in app on global level, so that retrofit throws an error i catch it in some specific class with logic for handling those errors. I have an interface @POST("/token") AuthToken refreshToken(@Field("grant_type") String…
ddog
  • 670
  • 1
  • 10
  • 25
21
votes
1 answer

What's the best way to debug RxJava problems with not received messages

I've an Android app with multiple observers of type A that subscribe with several Observables of type B. The subscription is done in IO Scheduler and the observation on the Android main thread. The problem that I've is that randomlly after some work…
lujop
  • 13,504
  • 9
  • 62
  • 95
20
votes
6 answers

Rxjava2 just method - how to run room insertion on another thread?

I have a room persistant database insertion method which looks like this: @Dao public interface CountriesDao{ @Insert(onConflict = REPLACE) List addCountries(List countryModel); } I realize that this can't be run on the…
j2emanue
  • 60,549
  • 65
  • 286
  • 456
20
votes
1 answer

Run void method in background

I want to run a method in background using rxjava. I don't care about the result. void myHeavyMethod() { (...) } So far the only solution I have is to modify the return type to e.g. boolean. boolean myHeavyMethod() { (...) return true;…
Marcin Kunert
  • 5,596
  • 5
  • 26
  • 52
20
votes
2 answers

What's the difference between fromCallable and defer?

fromCallable and defer have different implementation. I heard some say that defer helps with recursion but i can't produce any code that shows the difference between them. i tried with infinite number implementation: private Observable
piotrek
  • 13,982
  • 13
  • 79
  • 165
20
votes
1 answer

Chaining Singles together in RxJava

I am using RxJava in my android app along with Retrofit to make network requests to a server. I am using RxJavaCallAdapterFactory so I can have my retrofit requests return singles. In my code, the retrofit object is named 'api'. The code here works…
Jtvd78
  • 4,135
  • 5
  • 20
  • 21
20
votes
1 answer

RxJava onError Can't create handler inside thread that has not called Looper.prepare()

first i will try to explain what im trying to do, next you will see what im doing(code). Since im new at RxJava, and still learning fell free to give me your opinion. So, im calling a network API from server and when start request i call…
user1851366
  • 256
  • 6
  • 20
  • 41
20
votes
3 answers

Queue like Subject in RxJava

I'm looking for a Subject (or something similar) that can: Could receive items and hold them in a queue or buffer if there are no subscribers Once we have a subscriber all items are consumed and never emitted again I can subscribe/unsubscribe…
Martynas Jurkus
  • 9,231
  • 13
  • 59
  • 101
20
votes
4 answers

How do I handle exceptions in map() in an Observable in RxJava

I want to do this: Observable.just(bitmap) .map(new Func1() { @Override public File call(Bitmap photoBitmap) { //File creation throws IOException, …
Sree
  • 2,727
  • 3
  • 29
  • 47
20
votes
5 answers

How to create caching/hot version of rx.Single?

The RxJava v1.0.13 introduced new type of an Observable: rx.Single. It fits great the request-response model but lacks the standard side-effects introducing operators like doOnNext(). So, it's much harder to make multiple things happen as a…
atok
  • 5,880
  • 3
  • 33
  • 62
20
votes
2 answers

How to use TestScheduler in RxJava

How should I use RxJava's TestScheduler? I come from a .NET background but the TestScheduler in RxJava does not seem to work the same way as the test scheduler in .NET rx. Here is sample code that I want to test Observable tick =…
Calin
  • 6,661
  • 7
  • 49
  • 80