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
270
votes
9 answers

When should one use RxJava Observable and when simple Callback on Android?

I'm working on networking for my app. So I decided to try out Square's Retrofit. I see that they support simple Callback @GET("/user/{id}/photo") void getUserPhoto(@Path("id") int id, Callback cb); and RxJava's…
Martynas Jurkus
  • 9,231
  • 13
  • 59
  • 101
269
votes
5 answers

Difference between CompletableFuture, Future and RxJava's Observable

I would like to know the difference between CompletableFuture,Future and Observable RxJava. What I know is all are asynchronous but Future.get() blocks the thread CompletableFuture gives the callback methods RxJava Observable --- similar to…
shiv455
  • 7,384
  • 19
  • 54
  • 93
257
votes
3 answers

Use cases for RxJava schedulers

In RxJava there are 5 different schedulers to choose from: immediate(): Creates and returns a Scheduler that executes work immediately on the current thread. trampoline(): Creates and returns a Scheduler that queues work on the current thread to…
bcorso
  • 45,608
  • 10
  • 63
  • 75
195
votes
11 answers

When do you use map vs flatMap in RxJava?

When do you use map vs flatMap in RxJava? Say, for example, we want to map Files containing JSON into Strings that contain the JSON-- Using map, we have to deal with the Exception somehow. But how?: Observable.from(jsonFile).map(new Func1
Christopher Perry
  • 38,891
  • 43
  • 145
  • 187
174
votes
8 answers

What is the difference between flatmap and switchmap in RxJava?

The rxjava doc definition of switchmap is rather vague and it links to the same page as flatmap. What is the difference between the two operators?
Julian Go
  • 4,442
  • 3
  • 23
  • 28
160
votes
7 answers

Difference between Java 8 streams and RxJava observables

Are Java 8 streams similar to RxJava observables? Java 8 stream definition: Classes in the new java.util.stream package provide a Stream API to support functional-style operations on streams of elements.
rahul.ramanujam
  • 5,608
  • 7
  • 34
  • 56
151
votes
3 answers

Observable vs Flowable rxJava2

I have been looking at new rx java 2 and I'm not quite sure I understand the idea of backpressure anymore... I'm aware that we have Observable that does not have backpressure support and Flowable that has it. So based on example, lets say I have…
user2141889
  • 2,255
  • 5
  • 23
  • 25
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
121
votes
3 answers

Get response status code using Retrofit 2.0 and RxJava

I'm trying to upgrade to Retrofit 2.0 and add RxJava in my android project. I'm making an api call and want to retrieve the error code in case of an error response from the server. Observable apiCall(@Body body); And in the…
A.B.
  • 1,441
  • 3
  • 12
  • 10
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
110
votes
2 answers

Kotlin: Whats does "return@" mean?

I'm using RxJava in one of my projects, I converted one of my classes to Kotlin using the Android Studio plugin and in one of map flatMap lambda (Func1 in java), intermediates returns looks like the following @Func1. I have no idea what this means.…
Glenn Sonna
  • 1,853
  • 3
  • 19
  • 25
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
102
votes
8 answers

Combine a list of Observables and wait until all completed

TL;DR How to convert Task.whenAll(List) into RxJava? My existing code uses Bolts to build up a list of asynchronous tasks and waits until all of those tasks finish before performing other steps. Essentially, it builds up a List and…
Craig Russell
  • 3,534
  • 3
  • 26
  • 27
99
votes
17 answers

rxjava: Can I use retry() but with delay?

I am using rxjava in my Android app to handle network requests asynchronously. Now I would like to retry a failed network request only after a certain time has passed. Is there any way to use retry() on an Observable but to retry only after a…
david.mihola
  • 12,062
  • 8
  • 49
  • 73
94
votes
9 answers

@DELETE method is not supporting(Non-body HTTP method cannot contain @Body or @TypedOutput.)

@DELETE("/job/deletejob") Observable jobDelete( @Body JobDeleteRequestModel model); am getting this error: Non-body HTTP method cannot contain @Body or @TypedOutput
sandy
  • 943
  • 1
  • 6
  • 6
1
2 3
99 100