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
Category: RxJava
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
Observable defer method
In this post under RxJava, I will show with example how to create an Observable instance with the help of Observable class’s static method “defer”. In all my previous post, we used to create an Observable instance immediately for example Observable<Long> observable = Observable.interval(500, TimeUnit.MILLISECONDS); When the above code snippet is executed, it creates an…… Continue reading Observable defer method
Observable error and empty method
In this post under RxJava, I will introduce you to Observable class’s two static methods “error” and “empty” methods. The error method creates an Observable instance that will send the error thrown to the Observer/Subscriber. The empty method creates as Observable instance that will not send any item, it just generate completion event to the…… Continue reading Observable error and empty method
Observable interval method
In this post under RxJava, I will explain with example how to use the static “interval” method of Observable class. This static method generates a stream of numbers of data type long with a time gap between generation of numbers. They are two overloaded versions of “interval” method, one that accepts an intial delay in…… Continue reading Observable interval method
Observable range method
In this post under RxJava, I will explain with example how to use the static “range” method of Observable class. This static method generates a stream of integers which fall within the specified range. The method takes two arguments1) The starting integer2) The count of sequential integers from the starting integer. Below is an example…… Continue reading Observable range method
Creating Observable from collections
In this post under RxJava, I will explain with example how to create Observable instances from collections. The Observable api provides methods to create Observable instance from Java Array, Collections, and Streams. Below is an example of it Example 1 import java.util.ArrayList; 2 import java.util.List; 3 4 import io.reactivex.rxjava3.core.Observable; 5 6 public class Example2 {…… Continue reading Creating Observable from collections
Observable (Observable’s just method) With Simple Example
In this post under RxJava, I will explain what is an Observable with an example. An Observable is a push based stream of data/events. In other words an Observable pushes items of type T directly to the observer or indirectly to an observer through a chain of operators. Types of Observable They are four types…… Continue reading Observable (Observable’s just method) With Simple Example