September 2018
Intermediate to advanced
462 pages
13h 28m
English
In any given implementation of reactive programming, we will have Subscriber, which requests data, and Publisher, which provides the data. First, let's look at a sample Subscriber implementation:
import java.util.concurrent.Flow.*;public class packtSubscriber<T> implements Subscriber<T> { private Subscription theSubscription; // We will override the four Subscriber interface methods @Override public void onComplete() { System.out.println("Data stream ended"); } @Override public void onError(Throwable theError) { theError.printStackTrace(); } @Override public void onNext(T theItem) { System.out.println("Next item received: " + theItem); theSubscription.request(19); // arbitrary number } @Override public void onSubscribe(Subscription ...Read now
Unlock full access