Cold vs. Hot Observables
Learn about the differences between cold and hot observables.
We'll cover the following
Cold observable
An Observable
is considered cold if it is not actively emitting items. It only starts emitting items when it is subscribed to. Each subscription to a cold Observable
will cause it to emit the underlying sequence from beginning to end for each Observer
.
Note: The exact values of the sequence may differ for each
Observer
, depending on the underlying action theObservable
encapsulates as we’ll see more of this in the section Lazy Emissions.
Generally, a cold Observable
is what we would want if we want a complete copy of events emitted in the stream. It’s what we want for operations that should only be invoked when subscribed to: network operations, database queries, file I/O, and so on.
Looking at .just()
as an example, we see that the sequence is repeated on each subscription:
Get hands-on with 1200+ tech skills courses.