Category Archives for Reactive

Speacial Observables: Single, Maybe and Completable

October 12, 2018

There are a few special Observables available in RxJava: Single, Maybe and Completable. Single Single is an Observable that will emit only one item: it consolidates onNext() and onComplete() into a single event, so on subscribing to a Single, we can provide a Lambda for the onSuccess() and to the optional onError(): import io.reactivex.Single; public […]

Observable factories

October 11, 2018

There are various factory methods available to create Observables. In this post we will go through some of them. Observable.range() and rangeLong() In a previous post, we created an Observable using an IntStream. To emit a consecutive range of integers, there is a shorter solution available: import io.reactivex.Observable; public class Main { public static void […]

Cold and Hot Observables

October 10, 2018

A major characteristic of Observables is how they behave when there are multiple Observers. Based on this, we differentiate between Hot and Cold Observables. Cold Observables You can imagine Cold Observables like a DVD disk with a movie on it. Each viewer of the DVD can watch the whole movie at any time. Similarly, Cold […]

Differences between RxJava’s Observables and Java’s Streams

October 8, 2018

Stream processing libraries such as RxJava’s Observables and Java’s Streams are quite similar in their APIs for pipeline building. The main differences are how they handle multi-threading and the composition of said pipelines. Main differences Streams are pull-based, Observables are push-based. Streams can be used only once, Observables can be subscribed to multiple times. Using […]

Reactive Programming – Intro

October 7, 2018

Why? Why do we need Reactive programming? We all know the phrase: “If it is not broken don’t fix it”. So what is the problem for which we need a solution? Because if there is no problem, we don’t need a solution. That we need asynchronous programming, we can all agree. So the question is, […]