Questions tagged [rx-java2]

anything related to RxJava2 – The new implementation of the RxJava Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.

RxJava2 is the new implementation of the RxJava Reactive Extensions for the JVM – RxJava2 is a library for composing asynchronous and event-based programs using observable sequences for the Java VM.

It extends the observer pattern to support sequences of data/events and adds operators that allow you to compose sequences together declaratively while abstracting away concerns about things like low-level threading, synchronization, thread-safety and concurrent data structures.

4140 questions
41
votes
4 answers

RxJava Single.just() vs Single.fromCallable()?

I wondered if someone can shed some light on this question, when to use Single.fromCallable( ()-> myObject ) instead of Single.just(myObject) from the documentation, Single.fromCallable(): /** * Returns a {@link Single} that invokes passed…
bastami82
  • 5,955
  • 7
  • 33
  • 44
38
votes
2 answers

Do I have to unsubscribe from completed observable?

If an observable completes, do I still have to unsubscribe / dispose (in RxJava2) the observable to remove the Observer (prevent memory leaks) or is this handled internally by RxJava once a onComplete or onError event occurs? what about other types…
sockeqwe
  • 15,574
  • 24
  • 88
  • 144
37
votes
6 answers

How to reset a BehaviorSubject

I have a BehaviorSubject that I would like to reset - by that I mean I want the latest value to not be available, just as if it was just created. I don't seem to see an API to do this but I suppose there is another way to achieve the same result? My…
BoD
  • 10,838
  • 6
  • 63
  • 59
34
votes
6 answers

RxJava flatMapIterable with a Single

I'm trying to tidy up my code a little, and Single is looking like a good choice for me as I'm doing something that will only ever emit one result. I'm having an issue though as I was using flatMapIterable previously to take my response (a list) and…
spO_oks
  • 398
  • 1
  • 3
  • 9
34
votes
2 answers

Is there something like Single.empty()

I'm in the process of migrating from Rx 1 to Rx 2 and suddenly while reading through posts I found out that Single should be the type of observable to use for retrofit calls. So I've decided to give it a shot and while migrating our retrofit calls…
Fred
  • 16,367
  • 6
  • 50
  • 65
34
votes
5 answers

How to convert rxJava2's Observable to Completable?

I have Observable stream, and I want to convert it to Completable, how I could do that?
Stepango
  • 4,721
  • 3
  • 31
  • 44
33
votes
1 answer

Difference between doAfterTerminate and doFinally

Does anybody knows what is the difference between operators "doAfterTerminate" and "doFinally" in RxJava 2 ?
Andrii Turkovskyi
  • 27,554
  • 16
  • 95
  • 105
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
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
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
28
votes
3 answers

How to convert a List to PagedList and vice-versa?
PagedList is used for Android's cool paging library. To make the question as minimal as possible : If i have a list of strings like List stringList; // it consists of 200 strings I want to convert stringList to type…
28
votes
3 answers

RxJavaPlugins Error Didn't find class "com.google.devtools.build.android.desugar.runtime.ThrowableExtension"

After upgrading Android Studio 3.0 Beta 1 getting the following error. When I downgraded the error disappeared. Studio Build: Android Studio 3.0 Beta 1 Version of Gradle Plugin: 'com.android.tools.build:gradle:3.0.0-beta1' Version of…
Bulu
  • 1,351
  • 3
  • 16
  • 37
27
votes
4 answers

Method getMainLooper in android.os.Looper not mocked still occuring even after adding RxImmediateSchedulerRule

TrendingViewModelTest @RunWith(JUnit4::class) class TrendingViewModelTest { private lateinit var trendingRepository: TrendingRepository private lateinit var trendingViewModel: TrendingViewModel @get:Rule val schedulers =…
Manoj Perumarath
  • 9,337
  • 8
  • 56
  • 77
27
votes
3 answers

Convert RxJava Observables To Live Data With Kotlin Extension Functions

I've been using alot of RxJava Observables converted to LiveData in my code using LiveDataReactiveStreams.fromPublisher() library. So I though of adding an extension function to the RxJava Observable to easily convert them to LiveData. These are my…