---
title: "#kotlin-coroutines articles | Hashnode"
description: "Explore 80 articles tagged #kotlin-coroutines on Hashnode. Tutorials, guides, and how-tos from the community."
url: "https://hashnode.com/tag/kotlin-coroutines"
---

Tag

# #kotlin-coroutines

80 posts · 155 followers

[Android Expert](https://hashnode.com/@android-expert) · [Nov 2](https://hashnode.com/posts/why-your-flow-refuses-to-hop-threads-context-preservation-flowon-and-channelflow-in-kotlin/6ae8a26f660b8eb5185b74b4)

### [Why Your Flow Refuses to Hop Threads: Context Preservation, flowOn, and channelFlow in Kotlin](https://android-expert.hashnode.dev/why-your-flow-refuses-to-hop-threads-context-preservation-flowon-and-channelflow-in-kotlin?utm_source=hashnode&utm_medium=feed)

Why withContext breaks flow { } in Kotlin. Learn context preservation, when to use flowOn or channelFlow, and the Android failures that crash apps.

11 min read · [android-expert.hashnode.dev](https://android-expert.hashnode.dev/why-your-flow-refuses-to-hop-threads-context-preservation-flowon-and-channelflow-in-kotlin?utm_source=hashnode&utm_medium=feed)

[Android Expert](https://hashnode.com/@android-expert) · [Nov 2](https://hashnode.com/posts/dropped-on-the-floor-conflation-in-kotlin-flows-and-the-ui-events-you-never-saw/6ae88d60c9a2b6f165a55f3f)

### [Dropped on the Floor: Conflation in Kotlin Flows and the UI Events You Never Saw](https://android-expert.hashnode.dev/dropped-on-the-floor-conflation-in-kotlin-flows-and-the-ui-events-you-never-saw?utm_source=hashnode&utm_medium=feed)

Learn how Kotlin Flow conflation drops events in StateFlow, SharedFlow, and collectLatest, and fix it with Channels, buffers, and tested patterns.

11 min read · [android-expert.hashnode.dev](https://android-expert.hashnode.dev/dropped-on-the-floor-conflation-in-kotlin-flows-and-the-ui-events-you-never-saw?utm_source=hashnode&utm_medium=feed)

[Manuel Alejandro Hermoso](https://hashnode.com/@hermosotech) · [Oct 13](https://hashnode.com/posts/an-ai-agent-that-asks-before-it-pays-human-approval-for-tool-calls-in-kotlin/6ace917fc1d86b83bec23a5e)

### [An AI agent that asks before it pays: human approval for tool calls in Kotlin](https://deeptelar.hashnode.dev/an-ai-agent-that-asks-before-it-pays-human-approval-for-tool-calls-in-kotlin?utm_source=hashnode&utm_medium=feed)

Build a Kotlin AI agent that pauses before a tool call and waits for a person to approve it. The pause survives a restart, and the tests need no model

9 min read · [deeptelar.hashnode.dev](https://deeptelar.hashnode.dev/an-ai-agent-that-asks-before-it-pays-human-approval-for-tool-calls-in-kotlin?utm_source=hashnode&utm_medium=feed)

[Ganesh Rama Hegde](https://hashnode.com/@hegde10122) · [Feb 23](https://hashnode.com/posts/chapter-1-usecase01-coroutine-builders-and-execution-semantics/699bdee5a32af19cb6fcc92b)

### [Chapter 1 : UseCase01 - Coroutine Builders and Execution Semantics](https://kotlindeepdive.hashnode.dev/chapter-1-usecase01-coroutine-builders-and-execution-semantics?utm_source=hashnode&utm_medium=feed)

Mental Model: What Is a Coroutine? A coroutine is a suspendable computation, represented as a state machine, executed under a Job, scheduled by a dispatcher and resumed via a continuation. It is not a

13 min read · [kotlindeepdive.hashnode.dev](https://kotlindeepdive.hashnode.dev/chapter-1-usecase01-coroutine-builders-and-execution-semantics?utm_source=hashnode&utm_medium=feed)

[Ganesh Rama Hegde](https://hashnode.com/@hegde10122) · [Feb 21](https://hashnode.com/posts/chapter-30-usecase27-flow-cancellation-cooperative-cancellation/6999ddbd1ea55229dbb50438)

### [Chapter 30 : UseCase27 - Flow Cancellation & Cooperative Cancellation](https://kotlinflow.hashnode.dev/chapter-30-usecase27-flow-cancellation-cooperative-cancellation?utm_source=hashnode&utm_medium=feed)

Flow cancellation is not an optional feature. It is a core part of how coroutines are designed to behave. When a collector stops collecting, the entire upstream flow is cancelled automatically. This i

6 min read · [kotlinflow.hashnode.dev](https://kotlinflow.hashnode.dev/chapter-30-usecase27-flow-cancellation-cooperative-cancellation?utm_source=hashnode&utm_medium=feed)

[Ganesh Rama Hegde](https://hashnode.com/@hegde10122) · [Feb 20](https://hashnode.com/posts/chapter-27-usecase24-stateflow-state-holder-semantics/699893302de7857aa67d3417)

### [Chapter 27 : UseCase24 - StateFlow (State Holder Semantics)](https://kotlinflow.hashnode.dev/chapter-27-usecase24-stateflow-state-holder-semantics?utm_source=hashnode&utm_medium=feed)

What is StateFlow? StateFlow is a special type of SharedFlow that: Always holds a current value Requires an initial value Replays the latest value to new collectors Conflates updates automatically

3 min read · [kotlinflow.hashnode.dev](https://kotlinflow.hashnode.dev/chapter-27-usecase24-stateflow-state-holder-semantics?utm_source=hashnode&utm_medium=feed)

[Ganesh Rama Hegde](https://hashnode.com/@hegde10122) · [Feb 20](https://hashnode.com/posts/chapter-28-usecase25-hot-vs-cold-flow-comparison/699894629333793b50d6ea84)

### [Chapter 28 : UseCase25 - Hot vs Cold Flow comparison](https://kotlinflow.hashnode.dev/chapter-28-usecase25-hot-vs-cold-flow-comparison?utm_source=hashnode&utm_medium=feed)

In this use case we will do an architectural level comparison of hot versus cold flow. CODE IMPLEMENTATION package org.kotlinflowlearner.stockflow.usecases.uc25 import kotlinx.coroutines.flow.\* impor

4 min read · [kotlinflow.hashnode.dev](https://kotlinflow.hashnode.dev/chapter-28-usecase25-hot-vs-cold-flow-comparison?utm_source=hashnode&utm_medium=feed)

[Ganesh Rama Hegde](https://hashnode.com/@hegde10122) · [Feb 19](https://hashnode.com/posts/chapter-26-usecase23-sharedflow-hot-streams/699757f940a5f60bf0153abf)

### [Chapter 26 : UseCase23 - SharedFlow (Hot Streams)](https://kotlinflow.hashnode.dev/chapter-26-usecase23-sharedflow-hot-streams?utm_source=hashnode&utm_medium=feed)

Everything that we have seen until now was cold flows. Now we enter the world of "hot” flows. Cold flow means: Nothing runs until collected Each collector gets its own independent execution Flow re

4 min read · [kotlinflow.hashnode.dev](https://kotlinflow.hashnode.dev/chapter-26-usecase23-sharedflow-hot-streams?utm_source=hashnode&utm_medium=feed)

[Ganesh Rama Hegde](https://hashnode.com/@hegde10122) · [Feb 19](https://hashnode.com/posts/chapter-25-usecase22-context-switching-with-flowon/6997577230fd04958d5bed74)

### [Chapter 25 : UseCase22 - Context Switching with flowOn](https://kotlinflow.hashnode.dev/chapter-25-usecase22-context-switching-with-flowon?utm_source=hashnode&utm_medium=feed)

In this chapter we answer the core question : If Flow is sequential, then how do we control which thread executes which part? That’s what flowOn does. Flow is context-preserving by default. It means t

2 min read · [kotlinflow.hashnode.dev](https://kotlinflow.hashnode.dev/chapter-25-usecase22-context-switching-with-flowon?utm_source=hashnode&utm_medium=feed)

[Ganesh Rama Hegde](https://hashnode.com/@hegde10122) · [Feb 17](https://hashnode.com/posts/chapter-23-usecase20-buffering-for-performance/6994b4b4ba9dcc61b36fc361)

### [Chapter 23 : UseCase20 - Buffering for Performance](https://kotlinflow.hashnode.dev/chapter-23-usecase20-buffering-for-performance?utm_source=hashnode&utm_medium=feed)

There are real-world cases where producer is faster than consumer. By default, Flow is sequential. That means: Upstream emits Downstream processes Only then next value emits This is slow but safe. But differing speeds of producers and consumers ...

2 min read · [kotlinflow.hashnode.dev](https://kotlinflow.hashnode.dev/chapter-23-usecase20-buffering-for-performance?utm_source=hashnode&utm_medium=feed)
