Chapter 8. Heating up observables

 

This chapter

  • The difference between hot and cold observables
  • Working with WebSockets and event emitters via RxJS
  • Sharing streams with multiple subscribers
  • Understanding how hot and cold pertains to how the producer is created
  • Sending events as unicast or multicast to one or multiple subscribers

As you know, an observable function is a lazy computation, which means the entire sequence of operators that encompass the observable declaration won’t begin executing until an observer subscribes to it. But have you ever thought about what happens to all the events that occur before subscription happens? For instance, what does a mouse move observable do with all the mouse events or a WebSocket that has received a set of messages? Do these potentially very important occurrences get lost in the ether? The reality is that these active data sources won’t wait for subscribers to listen to begin emitting events, and it’s vital for you to know how to deal with this situation. Earlier, we briefly called out this idea that observables come in two different flavors: hot and cold. This isn’t a simple topic to grasp; it’s probably one of the most complex in the RxJS world, which is why we dedicate an entire chapter to it.

8.1. Introducing hot and cold observables

8.2. A new type of data source: WebSockets

8.3. The impact of side effects on a resubscribe or a replay

8.4. Changing the temperature of an observable

8.5. Connecting one observable to many observers

8.6. Summary