February 2019
Intermediate to advanced
442 pages
11h 46m
English
In a certain scenario, calling a Subscribe method on Publisher is not appropriate and you may want to write custom subscriber with own handling. Reactor framework provides support for defining custom subscribers by extending the reactor.core.publisher.BaseSubscriber<T> abstract class. You don't need to implement the Subscribe interface of Reactive Streams specification directly. Instead, you need to just extend this class to apply the custom implementation as follows:
static class CustomSubscriber extends BaseSubscriber<String>{ @Override protected void hookOnSubscribe(Subscription subscription) { System.out.println("Fetching the values ...!!"); subscription.request(10); } @Override protected void hookOnNext(String value) ...