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
34
votes
3 answers

Get the latest value of an Observable and emit it immeditely

I'm trying to get the latest value of a given Observable and get it to emit immediately once it's called. Given the code below as an example: return Observable.just(myObservable.last()) .flatMap(myObservable1 -> { return myObservable1; …
E-Kami
  • 2,529
  • 5
  • 30
  • 50
34
votes
1 answer

Comparison of Java reactive frameworks

I see many frameworks/libraries that claim that they can help build reactive applications in Java, such as: Akka, Vert.x, RxJava, Reactor, QBit, etc. They seem to have different approaches, features, pros, cons, etc. I could not find detailled…
Florian Beaufumé
  • 1,751
  • 2
  • 22
  • 34
33
votes
3 answers

When to unsubscribe a subscription

I have a question regarding how to unsubscribe an observable. I have two codes and I'm not really sure about which one is better. Example 1 -> Unsubscribe the subscriber once the stream has finished: Subscriber subscriber = new…
MarcForn
  • 3,321
  • 7
  • 25
  • 39
33
votes
3 answers

Handle Paging with RxJava

I'm using Retrofit + RxJava on an Android app and am asking myself about how to handle the API pagination to chain calls until all data is being retrieved. Is something like this: Observable getResults(@Query("page") int page); The…
Rafael Toledo
  • 5,599
  • 6
  • 23
  • 33
32
votes
2 answers

Creating Observable without using Observable.create

I am using RxJava in my Android app and I want to load data from the database. In this way, I am creating a new Observable using Observable.create() which returns a list of EventLog public Observable> loadEventLogs() { return…
Daniele Vitali
  • 3,848
  • 8
  • 48
  • 71
32
votes
2 answers

Scala streaming library differences (Reactive Streams/Iteratee/RxScala/Scalaz...)

I'm following the Functional Reactive Programming in Scala course on Coursera and we deal with RxScala Observables (based on RxJava). As far as I know, the Play Iteratee's library looks a bit like RxScala Observables, where Observables a bit like…
Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
31
votes
3 answers

RxJava : How to handle error with zip operator ?

I am using RxJava and RxAndroid with Retrofit2. Observable responseOneObservable = getRetrofitClient().getDataOne() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); Observable responseTwoObservable…
Priyank Patel
  • 12,244
  • 8
  • 65
  • 85
31
votes
5 answers

Cannot resolve symbol AndroidSchedulers

I'm using version 2.0.0 of RxJava, and it seems like I have no access to AndroidSchedulers. I'm unable to get access to mainthread through RxJava
syfy
  • 607
  • 3
  • 12
  • 19
31
votes
4 answers

How to get the request url in retrofit 2.0 with 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 url and it with the response data in sqlite as a cache Observable apiCall(@Body body); And in the RxJava…
何福毅
  • 323
  • 1
  • 4
  • 9
30
votes
3 answers

Difference between RxJava and RxAndroid?

Why do we need to use RxAndroid with RxJava? What is the functional difference between them and actual use of RxAndroid and RxJava? I can't find proper answer for this.
Drim
  • 514
  • 5
  • 18
30
votes
2 answers

RxJava `Completable.andThen` is not executing serially?

I have a usecase where I initiallize some global variables in a Completable , and in the next step in the chain (using andThen operator) I make use of those variables. Following sample explains my usecase in detail Say you have a class User …
doe
  • 971
  • 2
  • 11
  • 27
30
votes
2 answers

Single Observable with Multiple Subscribers

I have an Observable<> getFoo() that is created from a Retrofit Service and after calling the .getFoo() method, I need to share it with Multiple Subscribers. Calling the .share() method though, it causes the Network Call to be re-executed.…
Pavlos
  • 2,183
  • 2
  • 20
  • 27
30
votes
2 answers

rxjava add items after observable was created

I just started using rxjava and I got stuck. Maybe I'm not using rxjava in the right way, but I need to add items to an Observable after it was created. So I understand that You can just call Observable.just("Some", "Items") and the subscribers will…
Jelly
  • 4,522
  • 6
  • 26
  • 42
29
votes
3 answers

Which rxjava3 retrofit-adapter should we use for Rxjava3

I am using RxJava3 and retrofit but I am unable to get a rxjava3 retrofit-adapter for RxJava3.
Chetan Gaikwad
  • 1,268
  • 1
  • 13
  • 26
29
votes
4 answers

Best practice for disposing Completable, Single, Maybe and terminating Observables in RxJava

I'm asking this from an Android perspective, but this should apply to RxJava in general. As a best practice, should my view always dispose of even short lived Completable, Single, Maybe and terminating Observable Rx types that should terminate in…
HolySamosa
  • 9,011
  • 14
  • 69
  • 102