The Reactive Streams API introduced in Java 9 consists of the following four interfaces:
@FunctionalInterface
public static interface Flow.Publisher<T> {
public void subscribe(Flow.Subscriber<T> subscriber);
}
public static interface Flow.Subscriber<T> {
public void onSubscribe(Flow.Subscription subscription);
public void onNext(T item);
public void onError(Throwable throwable);
public void onComplete();
}
public static interface Flow.Subscription {
public void request(long numberOfItems);
public void cancel();
}
public static interface Flow.Processor<T,R>
extends Flow.Subscriber<T>, Flow.Publisher<R> {
}
A Flow.Subscriber object can be passed as a parameter into the subscribe() method of Flow.Publisher<T>. The publisher then calls the subscriber's onSubscribe() method and passes to it...