February 2019
Intermediate to advanced
672 pages
16h 50m
English
As the name implies, the main idea of reactive programming is to react to events. In the preceding section, we saw some examples of this idea with callbacks; you subscribe to them and the callback is executed as soon as the event takes place.
In reactive programming, this idea is expanded by thinking of events as streams of data. This can be exemplified by showing examples of such streams in RxPy. A data stream can be created from an iterator using the Observable.from_iterable factory method, as follows:
from rx import Observable obs = Observable.from_iterable(range(4))
In order to receive data from obs, we can use the Observable.subscribe method, which will execute the function we pass for each value that the data source emits: ...