I have SplashScreenFragment and inside this fragment, I’ll load the data from the server using Retrofit with RxJava, Getting data from the server will take between 1 second to 25 seconds. The SplashScreenFragment must show to the user for at least 8 seconds. When I get the data from the server, The onSu…
Tag: rx-java
What is the meaning of flatmap( return Observer::onComplete;) in rxJava? And why is the return type of it is Observerable?
I cannot understand the line of return Observer::onComplete; Answer It’s a fancy and incorrect way of doing an empty result á la Observable.empty(). fatMapObservable expects an Observable<POJO> as its return due to target typing. Since Observable is a single abstract method type, you can use a lam…
How to Mock LdapTemplate in Java and get full code coverage
I am trying to get full coverage on a very simple junit test using Mockito and am striking out. My disclaimer is that I am new to Mockito though what I am trying to do would seem pretty straightforward. Note that my junit test passes, it is just that the coverage is not complete. When the test is run, the
Any Rx operator which could FlatMap and return both the output
I want to know if there’s an appropriate RxJava operator for my use-case. I have the below two methods. These are retrofit interfaces. fun getSources(): Single fun getTopHeadlines(…
RxJava3. Why FlowableSubscriber onNext has not been called?
I need to get a Subscription object to have an opportunity of unsubscribing listeners. For this I want to give a FlowableSubscriber to function. Code: Logs are: If I use lambdas it works, but there is not onSubscribe callback. How can I get a subscription and why these mathods haven’t been called? Answe…
Why is doOnDispose not called?
When creating an Observable like this: doOnSubcribe is called, doOnDispose is not called. Why is that? Answer You need to use the doFinally() operator. doOnDispose() has a very narrow use case, where the observable is explicitly disposed. In your example, the observable terminates “naturally” by o…
Combine a list of Observables and wait until all completed
TL;DR How to convert Task.whenAll(List<Task>) into RxJava? My existing code uses Bolts to build up a list of asynchronous tasks and waits until all of those tasks finish before performing other steps. Essentially, it builds up a List<Task> and returns a single Task which is marked as completed whe…
Difference between CompletableFuture, Future and RxJava’s Observable
I would like to know the difference between CompletableFuture,Future and Observable RxJava. What I know is all are asynchronous but Future.get() blocks the thread CompletableFuture gives the callback methods RxJava Observable — similar to CompletableFuture with other benefits(not sure) For example: if c…
RxJava – Just vs From
I’m getting the same output when using Observable.just vs Observable.from in the following case: I thought just was just supposed to emit a single item and from was to emit items in some sort of list. Whats the difference ? I also noted that just and from take only a limited amount of arguments. So Obse…
What is the purpose of doOnNext(…) in RxJava
When should we use doOnNext() from Observable instead of just onNext()? Answer doOnNext is for side-effects: you want to react (eg. log) to item emissions in an intermediate step of your stream, for example before the stream is filtered, for transverse behavior like logging, but you still want the value to pr…