Observables
In the previous chapter, we created Observables from scratch and wrote subscribers to those Observables. In all of our examples, the Observables created an instance of the Producer
class. The Producer
class produces an event Stream. In other words, Observables are functions that connect subscribers to producers. Before we proceed, let's dissect an Observable and the core activities related to it:
- An Observable is a function that takes an Observer as a parameter and returns a function
- An Observable connects an Observer to a producer (producer is opaque for Observer)
- A producer is a source of values for an Observable
- An Observer is an object that has the
on_next
,on_error
, andon_completed
methods
What's a producer?
A Producer is a source of values for an Observable. Producers can be windows, timers, WebSocket's, DOM trees, Iterators over collections/containers, and so on. They can be anything that can be a source of data that can be passed on to an Observer. Next (value) ( In RxCpp
...