Components of RxPHP
Since this chapter is going to be mostly about Observables, observers and operators, we're going to start with them.
We've already seen a sneak peak in this chapter, and now we'll go into more detail.
Observables
Observables emit items. In other words, Observables are sources of values. Observers can subscribe to Observables in order to be notified when the next item is ready, all items have been emitted, or an error has occurred.
The main difference between an Observable (in the sense of reactive programming) and the observer pattern is that an Observable can tell you when all of the data has been emitted and when an error occurs. All three types of events are consumed by observers.
RxPHP comes with several basic types of Observables for general usage. Here are a few that are easy to use:
ArrayObservable
: This creates an Observable from an array and emits all values right after the first observer subscribes.RangeObservable
: This generates a sequence of numbers from a predefined...