Creating custom logic for Disposable

In this post under RxJava, I will show with example how to add custom logic when a subscription between Observable and Observer is being disposed. You can add custom logic in Disposable only if you are creating an Observable using callback style. In my previous post under RxJava I have shown you how to create…… Continue reading Creating custom logic for Disposable

ConnectableObservable’s refCount method

In this post I will explain “refCount” method with an example. In my previous posts under RxJava, I explained about ConnectableObservable’s “autoConnect” method. This method is similar to “autoConnect” method. By calling refCount is nothing but calling autoConnect and passing 1 as an argument. Observable<Long> observable = Observable.interval(1, TimeUnit.SECONDS); observable = observable.publish().refCount(); is similar to…… Continue reading ConnectableObservable’s refCount method

autoConnect vs connect method

In this post I will explain with example the difference between autoConnect and connect. In terms of similarities both are used with ConnectableObservable which is an Hot Observable. Both tells the Observable when to start emitting items. The difference being when to tell the Observable, at what point to start emitting items. For example, if…… Continue reading autoConnect vs connect method

Creating Custom Observable Using Callback Style

In this post under RxJava, I will show with example how to create a custom Observable using Callback style. In Callback style, a code is executed when a specific event occurs. In our case, the event is Observer subscribing to Observable. When this event occurs the callback code is called. For our example, we create…… Continue reading Creating Custom Observable Using Callback Style

ConnectableObservable autoConnect method

In this post under RxJava, I will explain with example the purpose of autoConnect method in ConnectableObservable class. We can use the autoConnect method to inform in advance how many observers will subscribe to the ConnectableObservable. Once the mentioned number of observers subscribe to the ConnectableObservable, the observable will behave like an cold observable and…… Continue reading ConnectableObservable autoConnect method

ConnectableObservale Example

In this post under RxJava I will explain with example what is a ConnectableObservale. They are two kinds of Observables. One is called Hot and another Cold. Whatever Observables you have seen in my previous posts are all Cold. You will see the differencebetween them when more than one Observer subscribes to the Observable. Whenever…… Continue reading ConnectableObservale Example

Creating Observable from Runnable, Callable, and Action

In this post under RxJava, I will explain with example how to create Observable from Runnable, Callable, and Action interfaces. When creating Observable from Runnable interface, the Observable will execute the code inside Runnable and either throw an error or just completes. When creating Observable from Callable interface, the Observable will execute the code inside…… Continue reading Creating Observable from Runnable, Callable, and Action

Creating a Custom Cold Stateful Observable

In this post under RxJava, I will show with example how to create your own custom cold stateful Observable using “generate” method. The custom cold stateful Observable will hold state information that’s why I said stateful in the previous statement. They are two versions of this method. Below are there syntax 1 -> public static…… Continue reading Creating a Custom Cold Stateful Observable

Creating a Custom Cold Stateless Observable

In this post under RxJava, I will show with example how to create your own custom cold stateless Observable using “generate” method. The custom cold stateless Observable will not hold any state information that’s why I said stateless in the previous statement. Below is the syntax of generate method Syntax public static <T> @NonNull Observable<T>…… Continue reading Creating a Custom Cold Stateless Observable