Part 3: Exploring Kotlin’s Cold Flow and Hot Flow

Dawinder Singh Gill
5 min readAug 10, 2023

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.

.

Stories about Kotlin Flow

6 stories

.

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…

--

--

Dawinder Singh Gill
Dawinder Singh Gill

Written by Dawinder Singh Gill

Expert native Android developer, skilled in Java, Kotlin, and Jetpack Compose. Adheres to best coding practices, excels in UI/UX design and app optimization.