Hot vs. Cold

Get an introduction to hot vs. cold.

Overview

Kotlin coroutines initially only had channels support, but creators noticed this wasn’t enough. Channels are a hot stream of values, but we often need a stream that’s cold.

Understanding the difference between hot and cold streams of data is useful software-craftsmanship knowledge because most data sources we use daily fall into one of these two categories. Collections (List, Set, etc.) are hot, while Sequence and Java Stream are cold. A Channel is hot, while Flow and RxJava streams (Observable, Single, etc.) are cold.

Note: This is true in general, but there are exceptions. Some functions and builders, like buffer or channelFlow, introduce some hotness into Flow. Also, SharedFlow and StateFlow are hot.

Get hands-on with 1200+ tech skills courses.