Jason Warner
1 min readMar 17, 2021

--

This is a really good read. I enjoyed a lot of the concepts shared. I did want to point out that the difference between hot and cold observables does not have to do with multi-cast or unicast observables.

The difference has to do with when observables start producing data. Cold observables start producing only when they have a subscriber. Hot observables are always producing regardless of if they have an observer or not. The best analogy that I have heard is that cold observables are like Netflix. The stream only starts when you start watching and stops or pauses when you want to. Hot observables are like over-the-air television. Shows are always broadcast. You can join a show at any point along with everyone else watching that show. However, you cannot rewind the show and the broadcast does not stop when you leave.

A concrete example in an Angular application is the `HttpClient`. You can multi-cast a request using the `HttpClient` using `publish()` and `refCount()` in fact, this is often a good idea to cut down on calls to a web server. However, `HttpClient` will not make the request until the first `.subscribe()`. A hot observable is the click stream from a user when interacting with your application. Whether you are subscribed or not, your user will continue clicking and interacting with your application and producing events.

--

--

Jason Warner
Jason Warner

Written by Jason Warner

I enjoy everything related to code and being a dev. However, my only skills are showing up and being lucky and I'm not sure if luck is a talent.

Responses (1)