- 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 onNext
, onError
and onComplete
terms and method names, you'll encounter just next
, error
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 onNext
, onError
and onComplete
.
All these terms are used in various literature and articles regarding Rx, so we'll tolerate all of them.
- Spring Boot 2實戰之旅
- TensorFlow Lite移動端深度學習
- C語言程序設計(第3版)
- 薛定宇教授大講堂(卷Ⅳ):MATLAB最優化計算
- 微信小程序開發解析
- Visual C++數字圖像處理技術詳解
- 用戶體驗增長:數字化·智能化·綠色化
- Apache Kafka Quick Start Guide
- Active Directory with PowerShell
- Geospatial Development By Example with Python
- Solutions Architect's Handbook
- Django 5企業級Web應用開發實戰(視頻教學版)
- SQL Server 2016 從入門到實戰(視頻教學版)
- The Statistics and Calculus with Python Workshop
- Web前端開發技術:HTML、CSS、JavaScript