Crash android device due to foreach in the functions of rxJava

I use rxJava in my application. And often i used such code: couponListInteractor.getObservableData(storeId) .subscribe(data -> data.forEach(item -> { if (!couponsCode.contains(item.getCode())) { couponsCode.add(item.getCode()); } } ); When i was dev

RxJava: Network & amp; the cache emits partial results

I have a simple case to resolve, but I haven't found how to implement it with RxJava yet. On one side I have Retrofit (network) and on the other side my SQLite database (cache). What I would like to achieve is : If there is nothing in the cache: call

sort list rxjava android with comparator class

I started to use rxjava with my android projects. I need to sort returning event list from api call. I wrote comparator class to sort list : public class EventParticipantComparator { public static class StatusComparator implements Comparator<EventPar

Android retrofit2 with sequential queries rx

I'm using retrofit2 with Rx. I have two API calls. If first call returns empty response with code 400 I need to make second API call, if not then just to show result. I've implemented custom error handling how shown here. Here is my solution: getResp

Android AsyncTask vs Thread + Handler vs rxjava

I know this is the question which was asked many many times. However there is something I never found an answer for. So hopefully someone can shed me some light. We all know that AsyncTask and Thread are options for executing background tasks to avoi

Retrofit 2 + Rxjava processing error

So i already receive a token from the Json when the login is made without problems, and receive the hash But when the response from the server is a error, i cannot get the Json message ({message:"Error : wrong email} " because in the onError we

Static generic method in class - Java

I am using RxJava on Android for doing some stuff, I always do the same stuff on the observable before using it like this : Observable<AnyObject> observable = getSomeObservable(); // The next 2 lines are the lines that i always add them to any Obser

RxJava- Turn Observable in Iterator, Stream or Sequence

I know this breaks a lot of Rx rules, but I really like RxJava-JDBC and so do my teammates. Relational databases are very core to what we do and so is Rx. However there are some occasions where we do not want to emit as an Observable<ResultSet> but

RxJava + Retrofit + interrogation

I have a Retrofit call and want to recall it every 30sec. To do that I use an Observable.interval(0, 30, TimeUnit.SECONDS) Observable .interval(0, 30, TimeUnit.SECONDS) .flatMap(x -> RestApi.instance().getUsers()) .observeOn(AndroidSchedulers.mainThr

Good use of Observable (RxJava)

I am already using RxJava + Retrofit + EventBus. It works great! But I'am not fully understand how to use Rx Observable as simple AsyncTask. I wil explain a bit: For example i have a method, which i want to do in background( not in UI thread): public

Combining the Firebase data listener in real time with RxJava

I am using Firebase in my app, along with RxJava. Firebase is capable of notify your app whenever something changed in the backend data (addition, removals, changes, ...). I am trying to combine the feature of Firebase with RxJava. The data I am list

RxJava - Schedulers vs ExecutorService?

I had a hunch that for highly computational, parallelized tasks in RxJava, a traditional ExecutorService would be faster than a Scheduler. I had a theory that this code Observable<MyItem> source = ... source.flatMap(myItem -> myItem.process().sub

sort a table in RxJS

RxJava has a method toSortedList(Comparator comparator) that converts a flow of objects into a list of objects sorted by a Comparator. How can I achieve the same in Javascript with RxJS and get an Observable of a flow of objects to emit a sorted arra

How to Queue API Calls When You Are Offline When Using Retrofit

I'm using Retrofit in combination with rx-java and have the following question: Is there a way to queue API calls to a server when the device is offline so that they can be fired when the device is back online again.You need to add queue to your proj

Cache Management with RXJava

I'm trying to implement this workflow with rxJava but i'm sure if i'm misusing or doing stuff wrong. User asks to login If a loginResult is available in cache then "emit" the cached LoginResult Else actually perform the request to the webservice

Java 8 equivalent of (RxJava) Observable # onComplete ()

I'm getting to know Java 8 Stream API and I am unsure how to signal to a consumer of a stream that the stream is completed. In my case the results of the stream-pipeline will be written in batches to a database or published on a messaging service. In

RxJava: observable that contains an asynchronous call

I'm trying to understand RxJava and running into the following situation. Consider the following method that returns an observable which calls NsdManager.registerService. The registerService method needs a listener which is called when registration s

RX: Run Zipped Observables in parallel?

So I'm playing around with RX (really cool), and I've been converting my api that accesses a sqlite database in Android to return observables. So naturally one of the problems I started to try to solve is, "What if I want to make 3 API calls, get the