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
44
votes
5 answers

Retrofit API call receives "HTTP FAILED: java.io.IOException: Canceled"

Can't figure out why is this happening. Neither one of rx callbacks (onCompleted(), onError(), onNext()) not gets triggered by my call. The only thing i receive is this okhttp output: D/OkHttp: --> GET…
oleg.v
  • 1,065
  • 3
  • 11
  • 20
44
votes
2 answers

RxJava Observing on calling/subscribing thread

I have some trouble understandig how subscribeOn/observeOn works in RxJava. I've created simple app with observable that emits solar system planet names, does some mapping and filtering and prints results. As I understand, scheduling work to…
Filip Zymek
  • 2,626
  • 4
  • 22
  • 31
43
votes
7 answers

How to stop and resume Observable.interval emiting ticks

This will emit a tick every 5 seconds. Observable.interval(5, TimeUnit.SECONDS, Schedulers.io()) .subscribe(tick -> Log.d(TAG, "tick = "+tick)); To stop it you can use Schedulers.shutdown(); But then all the Schedulers stops and it is…
Jan Seevers
  • 768
  • 1
  • 11
  • 20
43
votes
3 answers

RxJava: chaining observables

Is it possible to implement something like next chaining using RxJava: loginObservable() .then( (someData) -> { // returns another Observable with some long operation return fetchUserDataObservable(someData); }).then(…
Mikhail
  • 4,271
  • 3
  • 27
  • 39
42
votes
7 answers

How to call a method after a delay in android using rxjava?

I'm trying to replace my Handler method with RxJava. My requirement: I want to call the method getTransactionDetails() only after 5 seconds. This my working code using Handler: new Handler().postDelayed(new Runnable() { @Override …
Vibindas M
  • 483
  • 1
  • 4
  • 8
41
votes
4 answers

RxJava: Error occurred when trying to propagate error to Observer.onError

I am getting a IllegalStateException error in the Rx Library and don't know exactly where the root of the issue is, whether it is with RxJava or something I may be doing incorrectly. The fatal crash occurs when certificate pinning (occurs on all…
Scott B
  • 1,478
  • 2
  • 16
  • 26
41
votes
5 answers

RxJava - Just vs From

I'm getting the same output when using Observable.just vs Observable.from in the following case: public void myfunc() { //swap out just for from here and i get the same results,why ? Observable.just(1,2,3).subscribe(new…
j2emanue
  • 60,549
  • 65
  • 286
  • 456
40
votes
5 answers

RxJava and parallel execution of observer code

I am having the following code using RxJava Observable api : Observable observable = fileProcessor.processFileObservable(processedFile.getAbsolutePath()); observable .buffer(10000) .observeOn(Schedulers.computation()) …
Pawan Mishra
  • 7,212
  • 5
  • 29
  • 39
40
votes
3 answers

How do I get Response body when there is an error when using Retrofit 2.0 Observables

I am using Retrofit 2.0 to make api calls that return Observables. It all works good when the call went through fine and the response is as expected. Now let's say we have an error response, it throws an onError. I would like to read the response…
achie
  • 4,716
  • 7
  • 45
  • 59
40
votes
3 answers

How to properly handle onError inside RxJava (Android)?

I'm getting a list of installed apps on the device. It's a costly operation, so I'm using Rx for that: Observable observable = Observable.create(subscriber -> { List result = getUserApps(); subscriber.onNext(result); …
a_dzik
  • 927
  • 2
  • 11
  • 24
40
votes
8 answers

Convert observable to list

I am using RxJava. I have an Observable. How do I convert it to List? Seems to be a simple operation, but I couldn't find it anywhere on the net.
Khanh Nguyen
  • 11,112
  • 10
  • 52
  • 65
39
votes
4 answers

PublishSubject with Kotlin coroutines (Flow)

I used a PublishSubject and I was sending messages to it and also I was listening for results. It worked flawlessly, but now I'm not sure how to do the same thing with Kotlin's coroutines (flows or channels). private val subject =…
mayyyo
  • 513
  • 1
  • 5
  • 9
39
votes
4 answers

RxJava introduced Single. How do I convert an Observable to a Single?

RxJava recently introduced Single. Is there a way to convert an already existing Observable (that's pretty much a Single) to a Single without modifying the source of the original observable? For example, I have an api service class with a method…
loeschg
  • 29,961
  • 26
  • 97
  • 150
39
votes
2 answers

Difference between Java Concurrency, Akka and RxJava?

Today I found that, for concurrency in java we have good framework like Akka and I also found that, there is a reactive programming frameworks like RxJava for performing multithreading in application. But I'm still confused! Why are both better than…
Harmeet Singh Taara
  • 6,483
  • 20
  • 73
  • 126
39
votes
5 answers

How to create an Observable from OnClick Event Android?

I'm new in reactive programming. So I have problem when create a stream from an Event, like onClick, ontouch... Can anyone help me solve this problem. Thanks.
Thanh Le
  • 1,370
  • 2
  • 19
  • 30