# coroutines-flow

Published articles for coroutines-flow.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Understanding Dispatchers: Main and Main.immediate

DevFeed: [Understanding Dispatchers: Main and Main.immediate](<https://devfeed.tech/articles/understanding-dispatchers-main-and-main-immediate-25756.md>)

Original publisher: [Read original article](<https://blog.shreyaspatil.dev/understanding-dispatchers-main-and-mainimmediate/>)

Author: Shreyas Patil

Published: 2025-04-02T12:22:06Z

Content type: tutorial

Language: en

Sources: [Shreyas Patil's Blog](<https://devfeed.tech/sources/shreyas-patil-s-blog.md>)

Topics: [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [kotlin-coroutines](<https://devfeed.tech/topics/kotlin-coroutines.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Android](<https://devfeed.tech/topics/android.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-apps](<https://devfeed.tech/tags/android-apps.md>), [android-studio](<https://devfeed.tech/tags/android-studio.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [coroutines-flow](<https://devfeed.tech/tags/coroutines-flow.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-beginner](<https://devfeed.tech/tags/kotlin-beginner.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [main-thread](<https://devfeed.tech/tags/main-thread.md>), [multithreading](<https://devfeed.tech/tags/multithreading.md>), [reactive-programming](<https://devfeed.tech/tags/reactive-programming.md>), [threadpools](<https://devfeed.tech/tags/threadpools.md>), [threads](<https://devfeed.tech/tags/threads.md>)

### AI overview

A deep dive into Kotlin coroutine dispatchers on Android, explaining the difference between Dispatchers.Main and Dispatchers.Main.immediate. It describes how HandlerContext dispatches work and when execution is posted to the main thread or performed synchronously on the current thread.

### Source excerpt

A deep dive into Kotlin Coroutine Dispatchers. Understand the subtle but important difference between Dispatchers.Main and Dispatchers.Main.immediate in Android.

## Kotlin Flow Notes: Producers, Consumers, Operators, and Hot and Cold Flows

DevFeed: [Kotlin Flow Notes: Producers, Consumers, Operators, and Hot and Cold Flows](<https://devfeed.tech/articles/flow-notes-32051.md>)

Original publisher: [Read original article](<https://www.maiatoday.net/p/flow-notes/>)

Published: 2022-04-27T16:16:06Z

Content type: tutorial

Language: en

Sources: [maiatoday](<https://devfeed.tech/sources/maiatoday.md>)

Topics: [kotlin-flow](<https://devfeed.tech/topics/kotlin-flow.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Large Screen](<https://devfeed.tech/topics/large-screen.md>), [Streams](<https://devfeed.tech/topics/streams.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [article](<https://devfeed.tech/tags/article.md>), [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [cheat-sheet](<https://devfeed.tech/tags/cheat-sheet.md>), [code](<https://devfeed.tech/tags/code.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [coroutines-flow](<https://devfeed.tech/tags/coroutines-flow.md>), [flow](<https://devfeed.tech/tags/flow.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [kotlin-flow](<https://devfeed.tech/tags/kotlin-flow.md>), [sharedflow](<https://devfeed.tech/tags/sharedflow.md>), [sketch-note](<https://devfeed.tech/tags/sketch-note.md>), [stateflow](<https://devfeed.tech/tags/stateflow.md>), [streams](<https://devfeed.tech/tags/streams.md>)

### AI overview

A set of companion sketch notes about Kotlin Flow, covering suspend functions, streams of multiple values, producers and consumers, terminal and transform operators, execution contexts, hot and cold flows, and Android usage.

### Source excerpt

This post is my companion sketch notes for all the resources I consumed on the topic of flows. It is not meant to replace the info that I found on the internet but rather supplement it. Nor is it complete or should it be a standalone guide. In fact you can find an excellent list of my favourite resources at the end of the article. It is a document that helps me make sense of the topic. With that disclaimer out of the way... Let's take a step back and look at the suspend function. If your coroutine knowledge is rusty, freshen that up first. What if we want to provide multiple values? A stream of values that can be observed? Enter flows. At their most basic, flows have a producer and a consumer. The interface looks like this (spoiler it's just suspend functions under the hood) The consumer gets the multiple values by using a terminal operator. If I need to change the produced values along the way before consuming them, there are transform operators. How do I switch from main to io context? What's with the hot and cold flows? How do I remember which is which? Some practical hot flows. Flows on Android References Kotlin Coroutines Flow in a nutshell Kotlin Flows ~ an Android cheat sheet Kotlin Flows in Android summary Android flow Asynchronous Flow | Kotlin Flow under the hood: how does it really work KotlinConf 2019: Asynchronous Data Streams with Kotlin Flow by Roman Elizarov Kotlin Flows in a Nutshell FlowMarbles Android StateFlow and SharedFlow If you are reading this far I will reward you with an Android portait.

## Refactoring from LiveData to Coroutines & Flow

DevFeed: [Refactoring from LiveData to Coroutines & Flow](<https://devfeed.tech/articles/refactoring-from-livedata-to-coroutines-flow-25969.md>)

Original publisher: [Read original article](<https://jossiwolf.medium.com/refactoring-from-livedata-to-coroutines-flow-e73b6c59f5ad?source=rss-8efc0359e234------2>)

Author: Jossi Wolf

Published: 2020-08-24T16:29:47Z

Content type: tutorial

Language: en

Sources: [Stories by Jossi Wolf on Medium](<https://devfeed.tech/sources/stories-by-jossi-wolf-on-medium.md>)

Topics: [Refactoring](<https://devfeed.tech/topics/refactoring.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Android](<https://devfeed.tech/topics/android.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [coroutines-flow](<https://devfeed.tech/tags/coroutines-flow.md>), [flow](<https://devfeed.tech/tags/flow.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [livedata](<https://devfeed.tech/tags/livedata.md>), [main-thread](<https://devfeed.tech/tags/main-thread.md>), [migration](<https://devfeed.tech/tags/migration.md>), [network](<https://devfeed.tech/tags/network.md>), [refactoring](<https://devfeed.tech/tags/refactoring.md>), [rxjava](<https://devfeed.tech/tags/rxjava.md>), [threading](<https://devfeed.tech/tags/threading.md>), [ui](<https://devfeed.tech/tags/ui.md>)

### AI overview

This tutorial describes migrating Android repositories from LiveData to Kotlin Coroutines and Flow. It distinguishes one-shot operations from data streams and introduces migration helpers to preserve compatibility during a gradual refactor.

### Source excerpt

If you haven't, I recommend reading my other post about LiveData in Repositories. We recently joined a new project with heavy LiveData usage, everywhere. The search for main thread blockages led us down a rabbit hole of removing a significant portion of our LiveData usages. Here's how we migrated our Repositories from LiveData. We were faced with a tough challenge: We had to migrate as quickly and smoothly as possible -- there was no time for huge interruptions. Having all our repositories and lots of helper classes use LiveData, this left us with two options: Make sure we get threading right in all places that use LiveData Replace LiveData in our Repositories Making sure we're on the right thread everywhere and continuing to use LiveData would be the solution requiring fewer changes, but we would still be using LiveData for a use case it isn't really designed for. It can not be said often enough: LiveData has nothing to do in layers not related to UI! Keep it out of Repositories, DataSources! There use Flow or RxJava and only put LiveData in your ViewModels!It was very unfortunate that this was shown by Google as best practice. 😪 https://t.co/zOnbmyJYDP Agreed, 💯! We're actually working on revamping this guide which hasn't been updated with the latest recommendations for a looong time 🙈 Our code was also quite convoluted and hard to fix, so we decided to look for another option to handle asynchronicity. In an ideal world, refactoring it would have been easier, and we probably would have stuck with LiveData had our code been less convoluted. Our main requirement was for our replacement to fit with our existing mental model -- ViewModels being able to observe data from repositories where needed. Looking at our code, we were able to categorise our LiveData use cases into two categories: One-shot LiveData, for example, network calls Streams of data (e.g. for retrieving cached data before emitting fresh data) Our Replacement We looked around for a bit and decided to go wi