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.
4,137
questions
0
votes
0
answers
13
views
Observable.fromCallable() method inside not getting called
This is how i'm using the Observable.fromCallable(). In other classes its working fine, but not in some of the classes. Any help would be appreciated.
Observable
.fromCallable(() ->
...
0
votes
0
answers
54
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 ...
-1
votes
1
answer
43
views
Expected begin_array but was begin_object at line 1 column 2 path $ on Kotlin+Android
I called the PetFinder API to get data. When I wanted to show the data on screen I got this error. I used Call sequence to get data and I used enqueue on the ViewModel.
I tried to use fromJson() ...
0
votes
0
answers
25
views
Kotlin generics error when changing T to nullable
I have an app where I make an API call with RetroFit and the API response will have a standard format with the actual result in an object in the JSON. Every API call is wrapped in this object:
data ...
1
vote
1
answer
40
views
Kotlin coroutines onErrorReturn (RX Java counterpart)
In RX Java there is a possibility to provide a default value in case of error, with a variety of onError... methods.
What is the counterpart in Kotlin coroutines?
I understand I can wrap code inside ...
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
1
answer
22
views
How to create a sequential RxJava chain from Completable to Single?
I have a scenario where I need to create a sequential chain using RxJava in Kotlin. Specifically, I want to create a chain that starts with a Completable and then proceeds to a Single operation.
Here ...
0
votes
0
answers
6
views
i can't get object in fileds, how do i get i to make a message notif in android
objects in fields can change their data, I want to retrieve data in the field object to be used as a message. i use RxJava and retrofit.
{
"status": 422,
"success": false,
...
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
0
answers
6
views
How to interprete the effects on multiple `subscribeOn` and `observeOn` on TestObserver#triggerActions?
I have spent certain efforts on multiple rounds and occasion in truly understanding subscribeOn and observeOn. After I examined the blog when-multiple-subscribeons-do-have-effect word by word 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
47
views
Rx2AndroidNetworking that created by amitshekhar not work with android version 31 and above
I get this error message when making a request by Rx2AndroidNetworking.
java.lang.IllegalArgumentException: com.gomini.gominipassenger: Targeting S+ (version 31 and above) requires that one of ...
0
votes
0
answers
18
views
RxJava2 request optimization (android app)
I need an advice for RxJava2 optimization.
I'm working on a support chat for Android Application. I need to retrieve the List of ChatPOJO from the server (list of users available for chatting) and ...
0
votes
1
answer
89
views
Can't create handler inside thread Thread[RxCachedThreadScheduler-1,5,main] that has not called Looper.prepare()
I'm rewriting an Android app using retrofit + RxJava. I'm new about Retrofit and RxJava, so I have some problem and I can't solve the error:"
Can't create handler inside thread Thread[...
0
votes
0
answers
10
views
Observable.toFlowable() fails with out of memory error in rxjava2
Why does this fails with out of memory error
Observable.fromIterable(IntStream.range(1, 100000).boxed()
.collect(Collectors.toList()))
.toFlowable(...
0
votes
0
answers
22
views
android Replace callbacks with observables from RxJava2
37
Im using callback to observe asynchronous operations with Android, but I think that could be great replacing this listeners with RxJava, I also need retry 3 times when the callback call onError.
...
0
votes
0
answers
84
views
Use OpenApi v3 yaml to generate route and validator with Vertx
I'm in Vertx 4.3.4 with RX java, and I want to initialize my routes with a openapiv3.yaml and especially (the main purpose) validate user input of each declared route in yaml (with the input model too ...
0
votes
0
answers
18
views
Skipping incorrect values with onErrorResume
I have RxJava problem with onErrorContinue() which officialy not exist.
Observable.fromIterable(List.of(1,2,3,4,5))
.flatMap(int -> {
if ( p % 2 == ) { return Observable.error(new RuntimeException(&...
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
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
36
views
RXJava merge 2 observables where one has debounce and second one doesn't, if the second observable is fired, the first one should be canceled
I have search function in my app. Search works with 1 second of debounce, so that a user can continue to write search term before the app tries to find the result.
I've added a second observable for ...
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(...
0
votes
1
answer
67
views
Observable.interval() - How can I resume the interval if network call fails?
I have an Observable.interval() that I'm using an SDK to poll an API endpoint every 5 seconds.
So that means when I make the network call, there is a chance that it throws an error.
(usually the first ...
0
votes
3
answers
159
views
RxJava - How to avoid this race condition?
I'm trying to insert some data into the local database on a background thread with a Completeable inside the constructor of my ViewModel
public MainViewModel() extends ViewModel {
public ...
0
votes
0
answers
33
views
RxJava2 get exception when using Observable.fromIterable
Sometime, I've got an exception in my application. I'm using Observable.fromIterable to call parallel with a list callback Object.
Observable.fromIterable(callBackArray)
.map {
...
1
vote
0
answers
91
views
RxJava - How to return the last 2 items from a Flowable for a new Observer
I have a Flowable<String> that returns the LATEST set of String. This is part of a library class. Is there a way for me to return the last 2 strings when a new observer subscribes to this ...
0
votes
2
answers
29
views
Combine Singles and generate a data class Single
I have a question around Single and haven't been able to find a good answer for that yet.
I have to return a Single from a method where I get 2 Single sources. The problem is I need to use the output ...
0
votes
1
answer
77
views
RxJava - .andThen() never called after .flatMapCompletable()
I have a Observable with a chained Completeable with a chained Single that is called at an interval of 5 seconds.
public void getCoinPrices() {
disposable = Observable
....
0
votes
0
answers
42
views
RxJava - When to use Disposable vs DisposableObservers?
When would I use a disposable vs a disposable observer? I was always under the assumption that you use a disposable observer and call dispose() when you want to unsubscribe. What's the difference ...
0
votes
0
answers
30
views
D/OkHttp: <-- HTTP FAILED: android.os.NetworkOnMainThreadException Retrofit2 +RxJava2
I'm trying to learn how Retrofit+RxJava work and I'm testing some example. If I call a List of objects I can print on console this list of objects. Here below the code:
Disposable disposable = ...
0
votes
0
answers
70
views
How to block UI until Observable gets a response or timeout?
In my Android project I have a simple switch with a boolean interface to be imlemented later:
Switch (
text: String,
val isSwitchChecked: (Boolean) -> Unit
)
which I use like:
Switch("...
0
votes
0
answers
88
views
Attempt to invoke interface method ApiInterface.getArea(java.lang.String, java.lang.String)' on a null object reference - RETROFIT + RXJAVA
I'm new on Retrofit+ RxJava. I wrote some app using Volley and nothing else. Now I'm trying to understand how Retrofit + RxJava work. I'm testing them calling some web service I used in Volley.
I read ...
0
votes
0
answers
52
views
Rxjava3 onNext method is executed after a long delay
I use the following code to realize the countdown display at the millisecond level. After onSubscribe is executed, the onNext method is executed nearly one minute later.
This problem occurs ...
0
votes
1
answer
60
views
Split a stream, edit its fields then recombine it to a single stream
I have the following structure
--- Stream A [ A.map1.diff() ] ---
| |
| |
Source --- --- Stream B ...
0
votes
0
answers
121
views
Android. How to handle events with debounce?
I'm using library and handle event from library (for example onUpgrade). The problem is that this event can be called very often, therefore I need handle my onUpgrade event with debounce 3 seconds.
...
0
votes
0
answers
32
views
Handle onError inside lamda
I can handle onError like this using subscribe():
repository
.getData()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()...
0
votes
1
answer
96
views
RxJava fromCallable() and defer() difference in behaviour
I have implement a validate function, sample code are as below:
public class TestObject {
LocalDateTime d1;
LocalDateTime d2;
//getters, setters
}
public class ErrorResult {
String errorMsg;
...
0
votes
1
answer
59
views
rxjava - how to switch to previous stream but also do some work on main thread once first observable is ready?
I have two observables that both make network calls but they depend on each other:
val ob1 = Observable.just(myservice.getNewsArticles())
ob1.flatMap{ newsArticle -> myservice....
0
votes
0
answers
195
views
How to analyze memory consumption when running application inside container
I am running a RxJava-Micronaut with application and sqlite database inside the container. This application is having a scheduled job which process half millions string records from database (it calls ...
0
votes
1
answer
165
views
How can I delay the onSuccess and onError methods in RxJava?
I posted this question about how to delay the onSuccess method in RxJava about 9 months ago. Here is a summary of the question:
The SplashScreenFragment is a fragment that loads data from a server
...
0
votes
0
answers
27
views
Server connection status with RxJava in Android
I have a websocket connection
object StompWrapper {
private var emitter: ObservableEmitter<Event>? = null
init {
val client = OkHttpClient.Builder().build()
val stomp = ...
1
vote
0
answers
100
views
ExoPlayer - Player is accessed on the wrong thread with RxJava2
From past developers, I got a large library, which is built on the basis of ExoPlayer, which allows you to listen to audio books.
Everything worked fine until the library itself had to update the ...
0
votes
0
answers
51
views
Android RxJava Schedulers.computation() make the app laggy
currently I am using RxJava to do some heavy background work, unfortunately it seems like the work is quite heavy for some devices making the app "laggy" on these (for example animations).
I ...
0
votes
0
answers
29
views
Using backpressure in observables of cold type?
Since in Hot Observable , we must use backpressure strategy to prevent from crash but why we use backpressure for example in the following examples which are Cold type:
Example 1
// If we do not use ...
0
votes
0
answers
174
views
Rewrite RxJava code to Kotlin flow variant (especially repeatWhen operator)
I have an RxJava code:
private val refresh = PublishProcessor.create<Any>().toSerialized()
...
Single.fromCallable {
val number = 1
return@fromCallable number
}.repeatWhen { it....
0
votes
1
answer
33
views
How to create an Observable inside another Observable to receive part of the data?
By subscribing to getOrderBook I am getting data via Netty and Websocket. The first time a full OrderBook arrives, and then incremental updates follow. As a result, I get the complete OrderBook with ...
0
votes
0
answers
55
views
Android com.androidnetworking.common does not exist
I have issue with Rx2 Networking is not working. I have already added RXjava dependency in Gradle file but still getting this below error.
"error: package com.rx2androidnetworking does not exist
...
0
votes
0
answers
34
views
how to use a array of regular expression to terminate a loop in RxJava
I am working for a Classic Bluetooth App, I need read the weight from a Classic Bluetooth steelyard,
The bluetoothConnection read data from the steelyard like below, it will repeat wn00001.10kg
...
0
votes
0
answers
70
views
Handling multiple calls from Retrofit2 using RxJava2
I know there's some similar existing questions on this matter but none have worked so far and the amount of solutions via different versions of dependecies has gotten me confused.
Firstly, here are my ...