Part 3: Exploring Kotlin’s Cold Flow and Hot Flow
This story is a part of the series I have written on Flow API in Kotlin. If you are new to Kotlin Flow then I’ll suggest you check this series from the beginning.
.
.
Introduction
In this story, we’ll dive into the fascinating world of Kotlin’s Cold Flow and Hot Flow. We’ll learn how they are different and what makes them special for reactive programming. Whether you love Kotlin or just want to improve your skills, this journey will help you understand when and how to use Cold Flow and Hot Flow effectively. Let’s begin our adventure and unlock the secrets of these powerful streams!
1. Cold Flow
Cold Flow
is a type of Kotlin Flow that emits data only when there is a collector. It doesn't store any data and starts emitting values only when a collector subscribes to it. Each collector receives all the values from the beginning of the Flow independently, as if they have their individual flow. It's like a 1-to-1 mapping, where one Flow serves one collector, and…