- Hands-On Reactive Programming with Reactor
- Rahul Sharma
- 211字
- 2021-08-13 15:22:54
Stream subscriber
A subscriber is used to listen to events generated by a publisher. When a subscriber registers to a publisher, it receives events in the following order:

As a result, the subscriber has the following interface to handle all of these events:
public interface Subscriber<T> {
public void onSubscribe(Subscription s);
public void onNext(T t);
public void onError(Throwable t);
public void onComplete();
}
Let's cover each of these methods in detail, as follows:
- onSubscribe(Subscription s): As soon as a publisher has received a subscriber, it generates a subscription event. The generated subscription event is then received in the specified method.
- onNext (T): All data events generated by a publisher are received by the subscriber in the specified method. A publisher may or may not publish a data event before closing the stream.
- onCompletion(): This refers to the completion event, which must be handled by a subscriber. Once a completion event is received, the subscription is considered void.
- onError(): This refers to the error event, which must be handled by a subscriber. An error can occur at any moment—while building a subscription or while generating the next data event. In any case, the publisher must send the error event. Once the event is received, the subscription is considered void.
推薦閱讀
- 工業機器人虛擬仿真實例教程:KUKA.Sim Pro(全彩版)
- Java編程全能詞典
- 數據展現的藝術
- Circos Data Visualization How-to
- Visual Basic從初學到精通
- 高維聚類知識發現關鍵技術研究及應用
- Nginx高性能Web服務器詳解
- 基于單片機的嵌入式工程開發詳解
- Microsoft System Center Confi guration Manager
- 智能生產線的重構方法
- Word 2007,Excel 2007辦公應用融會貫通
- 中國戰略性新興產業研究與發展·增材制造
- INSTANT Adobe Story Starter
- HBase Essentials
- 工業機器人入門實用教程