Reactive programming
Reactive programming is a style of programming that's focused on reacting to events. The most common implementation of reactive programming is the RxJava library. There's also an extension library for Kotlin called RxKotlin, which provides extension functions for RxJava that make programming more convenient.
We can use reactive programming to handle a sequence of events or a sequences of events. This approach is based on the observable pattern, and these are the two most frequently used interfaces in RxJava:
ObservableSource: A basic interface for theObservableclass:
public interface ObservableSource<T> {
void subscribe(@NonNull Observer<? super T> var1);
}Observer: An interface that provides methods for receiving push-based notifications:
public interface Observer<T> {
void onSubscribe(@NonNull Disposable var1);
void onNext(@NonNull T var1);
void onError(@NonNull Throwable var1);
void onComplete();
}Observable is a class that provides...