官术网_书友最值得收藏!

Naming conventions in Reactive Extensions

When talking about Observables, we use terms such as emit/send value/item. Commonly, we say that an Observable emits an item, but we understand the same from an Observable sends a value as well.

By emit/send we mean that an Observable is calling the onNext method on an observer.

When talking about Observables, we use terms such as send error/complete notification/signal. We also often mention that an Observable completes, which means that an Observable has sent a complete notification.

By notification/signal we mean that an Observable is calling the onError or onComplete method on an observer.

In the preceding paragraph, we worked with a simple RxPHP demo that had one Observable, two operators and one observer.

This structure formed an operator/Observable chain. We'll understand the same thing from both of the terms operator chain and Observable chain (sometimes also referred to as a chain of Observable operators). This is because, from our perspective, we're chaining operators; but under the hood, each operator returns another instance of the Observable class, so, in fact, we're chaining Observables. In practice, this doesn't matter, so we'll just remember that these have the same meaning.

When talking about Observable chains, we sometimes use the term source Observable. This is the source of items in the chain. In other words, it's the first Observable in the chain. In the preceding example, the source Observable was Observable::fromArray($fruits).

When talking about operators, we use the term source Observable to also describe the Observable directly preceding this particular operator (because it's the source of items for this operator).

Sometimes instead of the onNextonError and onComplete terms and method names, you'll encounter just nexterror and complete. This comes from RxJS 5, which follows the ES7 Observable specification ( https://github.com/tc39/proposal-observable ), but their meaning is exactly the same. Most Rx implementations use the names  onNextonError and onComplete.

All these terms are used in various literature and articles regarding Rx, so we'll tolerate all of them.

主站蜘蛛池模板: 濮阳市| 根河市| 红原县| 平潭县| 太和县| 循化| 乌什县| 黄梅县| 齐齐哈尔市| 南涧| 长武县| 佛冈县| 海安县| 沅陵县| 乌拉特前旗| 石泉县| 长乐市| 阳江市| 宣化县| 梅州市| 右玉县| 崇阳县| 建昌县| 福鼎市| 固始县| 旬邑县| 富民县| 芮城县| 密山市| 壶关县| 布拖县| 梁河县| 当雄县| 古丈县| 阿拉善右旗| 宁安市| 石家庄市| 仲巴县| 张家界市| 兰西县| 新竹县|