Chapter 7. Controlling the observable temperature

 

This chapter covers

  • Creating publishers with subjects
  • Working with hot and cold observables
  • Moving from hot to cold and vice versa
  • Controlling the hot observable lifetime

The abstraction provided by observables hides from the observers the knowledge of how the underlying source makes the emissions. Depending on the way the observable is implemented, the same emissions (the object instance) might be shared between the various observers, or alternatively, each observer might get different instances. The observable might be implemented so that each observer receives the entire sequence, or instead receives part of the sequence, depending on when it subscribed.

Say an observable emits sound waves. As an observer, you don’t know whether the sound is coming from a live concert, or played from an album that was started the moment the observer subscribed. During a concert, all the listeners (the observers) share the same tunes. But when played from an album, the tunes are played to each listener independently, and the full sequence of songs can be consumed no matter when the observer subscribed.

7.1. Multicasting with subjects

7.2. Introducing temperature: cold and hot observables

7.3. Heating and cooling an observable

7.4. Summary