Hot/cold refers to whether a stream reference emits the same set of values to all subscribers...regardless of when they subscribe. Cold streams will emit the exact same data to all subscribers (the first subscriber and the last) no matter when they subscribe (xs.of('foo')
is a cold stream). Hot streams will not necessarily emit the same data to later subscribers. They're live. Subscribing to a hot stream means you may have missed previous emissions (or what would have been previous emissions had there been subscribers) and those emissions cannot be recovered.
For example, a stream which emits the current unix time every second may have no subscribers, but it's still a hot stream because it had valid emissions before you subscribed... but you missed them...
In xstream
where everything is multicast, what determines whether a stream is hot or cold (aka whether the stream may have had previous emissions that can't be recovered) is often whether there are existing subscribers to a stream reference. The first subscriber to a multicast source can cause the source to trigger some default/initial emission (see startWith
). Subsequent subscribers will not see that initial emission (..unless that source is remember
ed, which is a different discussion, and has no bearing on hot/cold, unicast/multicast), hence that stream is considered "hot". The multicast-ness is not what makes it hot. The multicast-ness combined with the fact that there is already a subscriber to the stream which may have triggered an unrecoverable emission, is what makes it hot...