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
1
vote
2 answers

RxJava using multiple observable (api calls) per one execution

I have something like: private Single> getFirstApiResponse() { return Single.just(....) ///// .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()); } private Single
Mike
  • 79
  • 2
  • 9
1
vote
1 answer

RxAndroid : How to emit zipped observable every minute?

Observable> zippedObservable = Observable.zip(observableList, objects -> { List stopList = Collections.emptyList(); for (Object obj : objects) { stopList.add((Stop) obj); } return stopList; }); I have the…
kimchistudent
  • 97
  • 2
  • 7
1
vote
1 answer

Is it possible to unit test list add/remove that happens in onSubscribe that gets undone in onComplete/onError without adding new methods to verify?

I have a completable that looks like below which I'm trying to test with Mockito. completable .doOnSubscribe { list.add(item) }.doOnError { list.remove(item) //do other stuff …
Ben987654
  • 3,280
  • 4
  • 27
  • 50
1
vote
1 answer

Rx - Combine new input with previous output

I have following case of Reducer: class XYZ Reducer(private val state: BehaviorRelay) { override fun invoke(events: Observable): Observable = events.ofType(Event::class.java).map { event -> …
Orbite
  • 505
  • 4
  • 8
1
vote
0 answers

RxJava2: onErrorResumeNext not intercepting 400 response code

I have below code for error handling. My issue is that when server sends a 400 error code the onErrorResumeNext is not being called. Is this expected? I thought onErrorResumeNext would be called when server sends a non 200 code(200-300). public…
1
vote
1 answer

switchIfEmpty does not emit vales from second observable if first one is empty

I'm using switchIfEmpty operator in RxJava to use a secondary observable when the primary observable doesn't have a value. Following is my code: fun main(args: Array) { getFirstObservable() .switchIfEmpty {…
Abhishek
  • 1,349
  • 8
  • 17
1
vote
1 answer

Flowable concatMapSingle without prefetch to ignore clicks until processing finishes

I want to handle clicks in such a way that they are ignored as long as I'm doing processing of some click that occurred. I thought I could do it by utilizing the backpressure, like this: private val clicks = PublishProcessor.create() //…
arekolek
  • 9,128
  • 3
  • 58
  • 79
1
vote
0 answers

How to pause and resume asynctask doin backround is it possible?

How to pause do in background in AsyncTask or what is the right way to download a music file with pause and resume and is it possible to do with rxjava2
1
vote
1 answer

JobService does not repeat

In Android Oreo, I want to create a service that periodically updates data from the network. class NetworkJobService : JobService() { override fun onStopJob(p0: JobParameters?): Boolean { jobFinished(p0,true) return true } override fun…
H.Kim
  • 525
  • 4
  • 14
1
vote
1 answer

RxJava2 create() caution

Reading the topic #2 from this article, it's clear that using create() properly can involve several issues, like: Unregister callbacks when an Observable is unsubscribed (failing to do so can cause memory leaks) Emit events using onNext or…
Michel Feinstein
  • 13,416
  • 16
  • 91
  • 173
1
vote
2 answers

Call network api just as activity is finishing

I have a preference screen in my application and I want to save the user preferences in the server, but I don't want any update button in the settings, I was hoping to make this update api call when the activity is finishing, maybe I can call the…
Saurabh Mishra
  • 306
  • 3
  • 12
1
vote
1 answer

RxJava2- Completable never ends

I'm new to the rxjava world and trying to implement the following scenario. Basically I want to make an api call and then save the info in the database in order to the next time I launch the app it loads the data from the db. So to achieve this I…
1
vote
1 answer

How to validate input using RxJava?

I have the following code submitButtonClickObservable .withLatestFrom(txtInputChangesObservable) .subscribe{ } It works well, but i want to handle clicking the submit button while the text input is not used and show the validation error.…
Nariman Ermekov
  • 185
  • 1
  • 11
1
vote
1 answer

RxJava2 how to update existing subscription when request parameter changes

I have an activity on which I make a network request everytime the user input changes. The api definition is as follows: interface Api { @GET("/accounts/check") fun checkUsername(@Query("username") username: String):…
Inn0vative1
  • 2,014
  • 3
  • 27
  • 43
1
vote
2 answers

Reuse part of RxJava stream

Probably an rx newbee question. If I have two rx streams, which have some common parts, is there a possibility to extract and to reuse them? Here is pseudo code example: someManager.getInfo(id) returns a Single This fun takes an id and…
Tima
  • 12,765
  • 23
  • 82
  • 125