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

Canceling multiple subscriptions at once in RxAndroid - Android

I use Retrofit with RxAndroid to handle couple of requests in one Activity, So I have couple subscription variables in the activity as public, public Subscription sub1; public Subscription sub2; public Subscription sub3; public Subscription…
MBH
  • 16,271
  • 19
  • 99
  • 149
3
votes
1 answer

RxJava api call for every item in list and return list of extended items

I use Retrofit 2 and I'm learning RxJava. I download a list of items from somewhere. I want to make an api call for each item and create a new list of extended items. Both calls return an Observable. It looks something like…
Herrbert74
  • 2,578
  • 31
  • 51
3
votes
1 answer

Read and write from a Socket simultaneously in RxJava

I'm an RxJava newbie trying to accomplish the following simple task: connect via a socket to a server that regularly sends data read the data as it arrives write a heartbeat message to the server every n milliseconds if the socket is writeable I…
3
votes
1 answer

RxJava: Is there some sort of chain which lets me "wait until observables A, B, C are complete before continuing"?

In jQuery, the idea of promises is done via: var taskA = $.Deferred(); var taskB = $.Deferred(); var taskC = $.Deferred(); // Callback starts when all tasks are complete/resolved $.when(taskA, taskB, taskC).done(function(results) { var resultA…
twig
  • 4,034
  • 5
  • 37
  • 47
3
votes
1 answer

Implementing Repository Pattern With RxJava

I'm trying to figure out a better way to achieve something like repository pattern in RxJava in Android. Here's what I have so far: (took some code from here) public Subscription getData(Observer observer, boolean refresh) { Subscription…
Fadli
  • 976
  • 9
  • 24
3
votes
2 answers

RxJavas Single. Where are its connected methods?

Lets say I want to make a network call and use a rx.Single as I expect just a single value. How can I apply something like replay().autoConnect() so the network call does not occur multiple times when I'm subscribing from multiple sources? Should I…
Paul Woitaschek
  • 6,717
  • 5
  • 33
  • 52
3
votes
1 answer

Chaining Observable & Emitting / Passing Original Emit to Subscribe Call

I have a use case where I'm consuming messages, saving them and then replying success or fail. The mongo insert returns an Observable so I can chain using flatmap. The issue is the insert Observable emits the result of the insert, but I need the…
zylum
  • 63
  • 3
3
votes
1 answer

Why to use new feature Single in RxJava?

Documentation is pretty clear about what this alternative of Observable doing: The Single class implements the Reactive Pattern for a single value response. See Observable for the implementation of the Reactive Pattern for a stream or vector of…
ar-g
  • 3,417
  • 2
  • 28
  • 39
3
votes
1 answer

RxJava - flatmap vs concatMap - why is ordering the same on subscription?

According to this thread conCatMap and flatmap only differ by the order in which items are emitted. So i did a test and created a simple stream of integers and wanted to see in what order they would be emitted. I made a small observable that would…
j2emanue
  • 60,549
  • 65
  • 286
  • 456
3
votes
3 answers

Realm + Retrofit + Rxjava

I'm trying to figure out a way to save my Parsed objects from retro into realm through rxjava observable. Right now I have an API call: fetchCatalogData().subscribeOn(Schedulers.io()) .subscribe(data -> …
jhysum
  • 41
  • 1
  • 2
3
votes
1 answer

Retrofit2 and kotlin

I'm try to combine Kotlin RxJava and retrofit2. @GET("/xxxxxxxxxxxx/{id}.json") fun getHotel(@Part("id") id : String) : Observable> When I try to call this method (getHotels()): var subscription =…
Illya Bublyk
  • 712
  • 6
  • 21
3
votes
1 answer

Prevent an Observable running for each subscription

This is a conceptual problem with reactive programming due to my misunderstanding, I think. I have an Observable that issues a network call returning JSON, which I filter(), looking at the JSON for an admin flag, and then perform actions in the…
mmm111mmm
  • 3,607
  • 4
  • 27
  • 44
3
votes
1 answer

RxJava: Conditionally catch error and stop propagation

I use Retrofit with RxJava Observables and lambda expressions. I'm new to RxJava and cannot find out how to do the following: Observable res = api.getXyz(); res.subscribe(response -> { // I don't need the response here }, error ->…
x-ray
  • 3,279
  • 5
  • 24
  • 37
3
votes
1 answer

RXJava - thread priority

I'm using following to get a ExecutorService for my subscriptions: public static ExecutorService getThreadPoolExecutorService(int threads) { int NUMBER_OF_CORES = Runtime.getRuntime().availableProcessors(); ThreadPoolExecutor…
prom85
  • 16,896
  • 17
  • 122
  • 242
3
votes
1 answer

Handling callbacks with RxJava

I am trying to understand what is the best way to handle a particular case, using RxJava. I need to return an Observable which handles the removal of an account from the Android AccountManager. Unfortunately, this action is asynchronous and it needs…
Daniele Vitali
  • 3,848
  • 8
  • 48
  • 71