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

  • PHP Reactive Programming
  • Martin Sikora
  • 351字
  • 2021-07-09 19:06:16

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.

主站蜘蛛池模板: 咸阳市| 丰顺县| 资中县| 宜丰县| 通海县| 玛多县| 宿州市| 定南县| 明水县| 桦甸市| 凤城市| 鄢陵县| 和平县| 长乐市| 土默特右旗| 依兰县| 连山| 华容县| 寻乌县| 陆川县| 廊坊市| 汝南县| 高雄县| 兴仁县| 桃园市| 莫力| 易门县| 舟曲县| 瑞丽市| 广西| 山阳县| 莱芜市| 古田县| 寿阳县| 紫云| 南通市| 沙湾县| 涪陵区| 合作市| 收藏| 青铜峡市|