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.
6,957
questions
0
votes
0
answers
16
views
Questions about data loading
I have a problem with data loading that I can't solve. When I use navigation to go to a new fragment and then go back, the data loading of recyclerview becomes very strange, its data will be ...
0
votes
1
answer
19
views
ViewModel and LiveData persist in destroyed fragment causing NPE on second access to fragment
I have a ViewModel that retrieves data from a single RxJava Observable using a Disposable.
internal class MyViewModel: ViewModel() {
internal var disposable: Disposable? = null
internal var ...
0
votes
1
answer
28
views
Room request, one to many relathionship
Given
I have two classes, 'inspection' and 'items,' which have a one-to-many relationship, meaning one inspection can have many items, and each item is associated with a single inspection."
and I'...
1
vote
2
answers
26
views
Why there is nothing in my recyclerview on the screen even though datas are shared on API?
I am trying to get data from local by using GET method. Here is Service codes.
This is Interface of API
interface API {
@GET("WeatherForeCast")
fun getweather(): Single<List<...
-1
votes
2
answers
48
views
lateinit property list has not been initialized
I have used Retrofit, RxJava and RecyclerView on the project and a problem has occurred immediately. Here the isMainActivity.kt file:
private lateinit var recyclerView: RecyclerView
private ...
0
votes
0
answers
55
views
Does CompositeDisposable.dispose() Interrupt Tasks.await() in an Rx Subscription?
Is it normal for Tasks.await() from com.google.android.gms.tasks to be interrupted when CompositeDisposable.dispose() is called in an Rx subscription? I thought Rx operations run to completion by ...
0
votes
0
answers
23
views
If you cancel/dispose DisposableSubscriber, onComplete event is not called
Using this code:
Disposable d =
Flowable.range(1, 5)
.subscribeWith(new DisposableSubscriber<Integer>() {
@Override
...
0
votes
0
answers
26
views
Sometimes not receiving flowable updates if room update happens immediately after insert
I am using room with rxjava and I have one database with 2 tables. The former table has fields id and status, where status can be 0 or 1. The latter has a foreign key which is the id from table 1.
In ...
0
votes
0
answers
18
views
RxJava - different schedulers for each observable inside combineLatest
I'm using combineLatest like in the example here -
Observables.combineLatest(
observable1,
observable2
)
.subscribeOn(schedulers.io())
....
1
vote
1
answer
32
views
"java.lang.AssertionError: Value not present" while testing Database implemented using Room & RxJava
I am very fresh to RxJava library, Reactive programming & Room Database. So I just learned recently that you have to test your Data Layer before working on it. So I am writing all these codes in ...
0
votes
0
answers
14
views
What happens when a subscription to RXJava's Single happens after the object has already emitted data? [duplicate]
I want to solve a data race issue in my program.
I thought about using RXJava's Single but due to the way the program runs, it's uncertain whether the receiver will be able to subscribe to the Single ...
0
votes
0
answers
19
views
Unit test an exception being thrown from RX errorHandler - kotlin/java
I'm writing a unit test which is testing a scenario an exception is being thrown from RX.
I do have an Rx errorHandler, and I want to throw the exception in this case.
RxJavaPlugins.setErrorHandler { ...
2
votes
2
answers
46
views
2 Maybe queries in ROOM+RXJAVA
I use ROOM + RXJAVA for SQLITE database in ANDROID application.
I have a problem. I need to insert a new record, but before that make a query for more information.
I use Maybe, Single and Completable.
...
0
votes
0
answers
25
views
rxjava: thenReturn Single.error vs thenThrow Exception
I am writing an unit test for methodOne and am trying to simulate an exception scenario.
Single<String> methodOne() {
methodTwo();
return Single.just("Hello");
}
Single<...
0
votes
0
answers
30
views
How to achieve long polling in Android with rxKotlin?
When I request api, the Server will send a response after 10 seconds. And after the client got the response, I had to request back the API immediately.
Like this:
fun getSampleApi() {
...
0
votes
0
answers
29
views
How to apply a function to each element of a rx-java Flowable?
How to apply a function to each element in a flowable? I am trying to apply a function to each item in a flowable publisher and collect the result but the function never gets called.
CompletionStage&...
0
votes
0
answers
15
views
how to get main thread variables in RxJava3
Say I have some variables stored in ThreadLocal and how can I fetch them in below 'mapper' method?
ThreadLocal<String> data = new ThreadLocal<>();
data.set("some data");
...
0
votes
0
answers
20
views
How to call one API with different paramet in Rx Kotlin in Android
This is function
fun deleteSingleVideoOneByOne(path: ArrayList<String>)
This is implementation
override fun deleteSingleVideoOneByOne(path: ArrayList<String>) {
val apiService = ...
0
votes
0
answers
22
views
Why is Callback passed to RxJava map operator not being called?
UPD: I found a reason of this. I used String as a response type for getPlayerHtml request. Because of that it silently threw an Exception about malformed json etc. I needed to use ResponseBody from ...
0
votes
1
answer
26
views
Why do cores in the computation scheduler work on distinct cores in RxJava?
The main question is in the title, so I'll clarify a bit. I understand that count of threads in the computation scheduler equals to the amount of CPU cores. But why do these threads MUST run on ...
0
votes
1
answer
52
views
How to zip for Maybe when one of it is empty
I'm trying to zip multiple sources of Maybe, but there is a possibility that one of it could be empty.
Maybe<ObjectA> aMaybe = Maybe.just("1");
Maybe<ObjectB> bMaybe = Maybe....
0
votes
2
answers
49
views
Error: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $ - RxJava
I am calling an API using RxJava and Retrofit and storing the data in data class of kotlin. While calling the api, an error is thrown : java.lang.IllegalStateException: Expected BEGIN_ARRAY but was ...
0
votes
0
answers
89
views
How to Convert RxJava (Observable) to Kotlin Flow?
I have a piece of countdown code on which I applied the Observable.create((ObservableOnSubscribe) operator and I want to convert it to Kotlin Flow. Do you have any ideas on how I can achieve this?
if (...
0
votes
0
answers
28
views
Transform Callback into Observable with data from other Observable
I'm new to RxJava and I got a question about transforming callbacks into Observables.
I have this function that uses a callback.
client.loadAsync(body, object : Callback {
override fun onSuccess(...
0
votes
0
answers
25
views
RxJava - Adding new duplicate observer each call
I have a function that gets called from the response of a Flowable. It's an API request that returns a Single.
private fun syncUser() {
getUserUseCase.getUser() //Flowable DB (Room) call
...
0
votes
1
answer
44
views
How to execute for loop one by one synchronous in ex kotlin
private fun sendListOfFeedBack(listOfFeedBack: ArrayList<FeedbackModel>, email: String,
firstName: String,
lastName: String,
...
0
votes
0
answers
17
views
On Android, is ”Observable.interval(RxJava)“ affected by power saving policies?
Does it continue to run after the screen is turned off?
I have added the app to the battery-optimized whitelist, and created ForegroundService.
0
votes
0
answers
32
views
RxJava compatibility with Rsocket
Im going through RSocket implementation for Java using this https://github.com/rsocket/rsocket-java, but could only find Reactor support(Flux,Mono)
I cannot see any RxJava(Observables) support with ...
0
votes
0
answers
13
views
Can a RxJava chain emit 2 items for a single event emission by its source observable?
I am trying to emit UI State based on an UIEvent. The UIEvent is a PublishSubject which feeds events into the following rx chain
private val speciesStateObservable:Observable<PokemonListViewState&...
0
votes
0
answers
19
views
Whats the right way of managing transactions in Reactive Programming?
During synchronous method calls, we know how to manage transactions, for eg. we have @Transactional annotation in Spring Boot. But, how can we manage transactions in Reactive Programming (eg. RxJava), ...
1
vote
1
answer
82
views
How to add andthen() operator under condition or inside a loop Rx Kotlin
I'm trying to chain some rx operations under a condition but the andthen() inside the apply does not execute. Is this correct? operation returns a Completable. Android studio gives me the warning &...
0
votes
0
answers
22
views
Should dispose() be called on the same thread if I want to make a new subscription right away?
Have a look at the following code:
init {
disposable = itemsDao.getAll()
.observeOn(AndroidSchedilers.mainThread())
.subscribe { newItems ->
items.clear()
items.addAll(...
1
vote
0
answers
29
views
RxJava how to intersperse a Flowable?
I'm new to rx-java, I'm comming from the akka world. In akka-streams there is a convinient intersperse function and I would like to know how to do the same on Flowable? so something like
Flowable
....
0
votes
0
answers
26
views
How RxJava avoid deadlock and how it never runs out of I/O threads?
How RxJava avoid deadlock and how it never runs out of I/O threads?
I understood that Rxjava has a limited pool of i/o threads. Why it never runs out of I/O threads?
How RxJava avoid deadlock and how ...
-4
votes
1
answer
68
views
What is best way to call any method after every 30 seconds
i need to call a method on every 30 seconds what is the best way Handler, Observable.interval() or is there any other efficient way
4
votes
1
answer
2k
views
Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules jetified-kotlin-stdlib-1.8.10
My project is in Java , but when i tried to compile the project , it throws kotlin-related error that there are duplicate classes whereas i'm not really using any kotlin dependency or kotlin , any ...
0
votes
1
answer
30
views
Unexpected behavior in RxJava with observables constructed using AtomicIntegers
Here's the test case:
import io.reactivex.rxjava3.core.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
public class MainTest {
public static AtomicInteger ...
1
vote
0
answers
81
views
RxJava3 Observers, Disposables and CompositeDisposable [closed]
I am confused with RxJava's practices of getting job done.
I have tried executing Observable by:
implementing Observers for each Observable.
creating Disposables by implementing Consumer in subscribe ...
0
votes
1
answer
457
views
androidx.lifecycle.LiveDataReactiveStreams class not found after version 2.6.0
I just started to play with LiveData.
I followed the official Android documentation to import the different artifacts. Everything was fine until I needed to convert an Observable to LiveData. But ...
0
votes
1
answer
23
views
Return value from DB operation in Single<Long>
I am adding a record in my database (Room) and it returns the ID of the inserted record. For example, I add a row and it returns the number 5 (which is a Long).
When that operation is complete, I need ...
0
votes
0
answers
70
views
How to run a set of callables in parallel by using Flowable and Single
I have 4 blocking operations and would like to run them in parallel by using RxJava Single/Flowable.
The test code that I wrote to check parallelism is:
final Single<Boolean> f1 = Single....
0
votes
1
answer
48
views
How to trigger MutableLiveData change in ui?
In my view model I'm using an observable with zip operator to combine two data sets where I then create a new object with data from each source. I post the value of the object to my ui. I need to be ...
0
votes
1
answer
45
views
Implemented Peripheral 1 with Native Android API and implemented Peripheral 2 with RxAndroidBle Possible Conflicts
I'm working with code that's programmed using the Native BLE APIs. It has its own queue implementation for sending/writing characteristics. But I've also had the need to implement a second peripheral ...
0
votes
0
answers
39
views
How do I delete elements from Flowable that exist in second Flowable?
I need to save some data do database.
I have Flowable with data that i get from the server, and Flowable of data from my db.
I need to save only the data that is not already in the db.
I tried to do ...
0
votes
0
answers
72
views
How to bring this data class to these funtions in the viewmodel in Android Studio
So this is a project that I am jumping on and i want to keep the structure of the project intact. I think i got the API call right, since the project is using RxJava. My question is lifting the call ...
0
votes
1
answer
101
views
Unit testing service method in Spring Boot
I have been doing unit testing with JUnit 5 and Mockito for the following code that I am going to show you, but it is not working correctly. I want to evaluate the successful case.
public Maybe < ...
0
votes
0
answers
48
views
Why is backpressure important with RxJava when the Publisher and Subscriber are on the same Thread?
Take the following RxJava code:
public class IntervalObserverTest {
@Test
public void test() throws InterruptedException {
CountDownLatch latch = new CountDownLatch(10);
...
0
votes
1
answer
91
views
RxJava. Why operators like timer(), delay(), etc. use the computation scheduler by default?
The computation scheduler is needed for CPU-intensive tasks, so why does RxJava use it for delaying in operators like delay(), timer(), interval(), etc.?
Is delaying a CPU intensive task? Can we have ...
0
votes
0
answers
27
views
How to Stop Execution After a Certain Time using RxJava
I am very new to Rx java programming ,I am want to develop a API using Rx java programming which should stop execution after a certain time for example lets assume after 120 minutes. How I can achieve ...
0
votes
1
answer
39
views
RxJava - Conditional merging operations and asserting exception
I'm having one method which performs multiple conditional validations. I'd merge all validation into stream and assert if any exception occured.
public Observable<Void> performValidation(...