# coroutines-flow

Kotlin Flow is an asynchronous data-stream technology in kotlinx.coroutines that sequentially emits values and completes normally or with an exception.

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

## Don't Just Create a Flow. Know Where to Create It.

DevFeed: [Don't Just Create a Flow. Know Where to Create It.](<https://devfeed.tech/articles/don-t-just-create-a-flow-know-where-to-create-it-134270.md>)

Original publisher: [Read original article](<https://proandroiddev.com/dont-just-create-a-flow-know-where-to-create-it-8184bd4cb6eb?source=rss----c72404660798---4>)

Author: chanzmao

Published: 2026-11-14T14:18:24Z

Content type: article

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Dependency Inversion](<https://devfeed.tech/topics/dependency-inversion.md>), [Publish-subscribe pattern](<https://devfeed.tech/topics/pubsub.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [api](<https://devfeed.tech/tags/api.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [callback](<https://devfeed.tech/tags/callback.md>), [database](<https://devfeed.tech/tags/database.md>), [flow](<https://devfeed.tech/tags/flow.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [mobile-app-development](<https://devfeed.tech/tags/mobile-app-development.md>), [repository](<https://devfeed.tech/tags/repository.md>), [room](<https://devfeed.tech/tags/room.md>), [software-architecture](<https://devfeed.tech/tags/software-architecture.md>), [source](<https://devfeed.tech/tags/source.md>), [suspend](<https://devfeed.tech/tags/suspend.md>), [ui](<https://devfeed.tech/tags/ui.md>)

### AI overview

Use the data source's existing Flow directly for observable Room queries and DataStore values. Bridge callback or listener APIs with `callbackFlow` in the data source, where registration and cleanup via `awaitClose` belong. Keep one-time suspend operations as suspend functions unless a stream is actually needed; collecting a Flow wrapper would rerun the operation on each collection. Repositories can map, combine, or switch among existing streams, while ViewModels derive UI state and use `stateIn()` to expose it as `StateFlow`. The article's guiding division is to convert at the source, transform in the Repository, and derive UI state in the ViewModel; it presents this as a typical approach, not a rule that every operation must use Flow.

### Source excerpt

Understanding the Architectural Timing of Flow Conversion in Kotlin and Android. Image created by AI Kotlin Flow makes it easy to work with asynchronous data streams. We can use it to observe database changes, listen for network updates, combine multiple data sources, and expose reactive data to the UI. But there is a design question that often gets overlooked: Where should we actually convert data into Flow? It's easy to wrap an API in flow {}or callbackFlow and call it a day. But doing so in the wrong layer can make an architecture unnecessarily complicated. We may end up moving callback management into the Repository, wrapping one-time operations in streams, or creating Flow objects that serve no real purpose. A better approach is to introduce Flow close to the source of the data, then let higher layers work with that stream. Let's look at what this means in practice. Start with the Data Source Different data sources expose data in different ways. Some provide callbacks, others return values through suspend functions, and some already support Flow. The first step is to understand how the underlying API delivers data. Database: Use Flow Directly Room already supports observable queries. @Query("SELECT * FROM items") fun observeItems(): Flow<List<ItemEntity>> We don't need to create another Flow around this query. Room already handles change observation and emits updated results when the underlying data changes. The same principle applies to DataStore: val showAds: Flow<Boolean> = dataStore.data.map { preferences -> preferences[SHOW_ADS] ?: true } The data source already provides a stream of changes. We should use it directly rather than introducing another abstraction. Callback APIs: Use callbackFlow Android APIs often rely on callbacks or listeners to report changes. For example, consider a location API that delivers updates through a listener. fun observeLocation(): Flow<Location> = callbackFlow { val listener = LocationListener { location -> trySend(location) }

## Kotlin Flow Debugging: Trace combine and flatMapLatest with onEach

DevFeed: [Kotlin Flow Debugging: Trace combine and flatMapLatest with onEach](<https://devfeed.tech/articles/kotlin-flow-debugging-trace-combine-and-flatmaplatest-with-oneach-105767.md>)

Original publisher: [Read original article](<https://proandroiddev.com/kotlin-flow-debugging-trace-combine-and-flatmaplatest-with-oneach-863b337f945f?source=rss----c72404660798---4>)

Author: chanzmao

Published: 2026-10-29T01:59:28Z

Content type: tutorial

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Functional programming](<https://devfeed.tech/topics/functional-programming.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [flow](<https://devfeed.tech/tags/flow.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [logging](<https://devfeed.tech/tags/logging.md>)

### AI overview

Kotlin Flow's `onEach` operator lets you log each emitted value without changing it, but its action runs only when the Flow is collected. Place it on inputs to `combine` and around pipeline operators to see emissions, recomputations, and where values are filtered or transformed. With `flatMapLatest`, log the outer queries and inner results separately; use `onCompletion` to inspect a prior inner Flow's completion cause when a new query cancels it. These logs help reveal behavior, but close or concurrent emissions do not guarantee a one-to-one causal order with `combine` calls. For exact correlation, the excerpt recommends explicit event identifiers or separately modeled trigger events. Emission logs also do not show internal work such as when a network request starts or the server responds; log at the repository or network boundary for that.

### Source excerpt

Inspect emissions, find unexpected recomputations, and debug Flow pipelines with minimal code. Image created by AIWhere Did This Emission Come From? Kotlin Flow makes it easy to build declarative data pipelines. We can combine multiple streams with combine, switch between upstream flows with flatMapLatest, and transform values with operators such as map and filter. But as a pipeline grows, debugging becomes surprisingly difficult. Imagine a ViewModel that combines repository data, a search query, and a UI preference: val uiState = combine( repository.items, searchQuery, showAds, ) { items, query, showAds -> createUiState(items, query, showAds) } When createUiState() runs, which input triggered it? Did the repository emit new items? Did the user change the search query? Did the ad preference change? Or did several inputs emit values in quick succession? The combine lambda receives the latest value from every upstream Flow, but it doesn't tell us which Flow emitted most recently. We could introduce wrapper classes, restructure the pipeline, or add logging throughout the codebase. However, for everyday debugging, there is a much simpler solution: onEach. It lets us inspect values as they pass through a Flow without transforming them or changing the pipeline's data model. Let's see how to use it effectively. Why onEach Is the Easiest Way to Inspect a Flow The onEach operator performs an action for every emitted value before passing that value downstream. flow .onEach { value -> println("Emitted: $value") } .map { value -> transform(value) } The important point is that onEach doesn't transform the emitted value. This makes onEach ideal for temporary diagnostic logging. We can insert it into an existing pipeline, inspect what's happening, and remove it when we're done. There is one important detail: Flow is generally lazy. Adding onEach doesn't start collection by itself. Its action runs only when the Flow is collected and an upstream value is emitted. Identify Which Flow

## Kotlin Flow: Bugs That Look Correct at First

DevFeed: [Kotlin Flow: Bugs That Look Correct at First](<https://devfeed.tech/articles/kotlin-flow-bugs-that-look-correct-at-first-105704.md>)

Original publisher: [Read original article](<https://kt.academy/article/kaustubh_flow_bugs_that_look_correct_at_first>)

Published: 2026-10-26T00:00:00Z

Content type: article

Language: en

Sources: [Kt. Academy](<https://devfeed.tech/sources/kt-academy.md>)

Topics: [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [bugfixes](<https://devfeed.tech/topics/bugfixes.md>), [coroutine-testing](<https://devfeed.tech/topics/coroutine-testing.md>), [Exception handling](<https://devfeed.tech/topics/exception-handling.md>), [Exception](<https://devfeed.tech/topics/exception.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [api](<https://devfeed.tech/tags/api.md>), [apis](<https://devfeed.tech/tags/apis.md>), [buffer](<https://devfeed.tech/tags/buffer.md>), [bugs](<https://devfeed.tech/tags/bugs.md>), [cancellation](<https://devfeed.tech/tags/cancellation.md>), [capacity](<https://devfeed.tech/tags/capacity.md>), [collector](<https://devfeed.tech/tags/collector.md>), [collectors](<https://devfeed.tech/tags/collectors.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [database](<https://devfeed.tech/tags/database.md>), [error-handling](<https://devfeed.tech/tags/error-handling.md>), [exception](<https://devfeed.tech/tags/exception.md>), [exceptions](<https://devfeed.tech/tags/exceptions.md>), [execution](<https://devfeed.tech/tags/execution.md>), [flow](<https://devfeed.tech/tags/flow.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

### AI overview

The excerpt explains four Kotlin Flow pitfalls and how to address them. Collecting a cold flow separately for multiple consumers reruns its upstream work; use `shareIn()` when those consumers should share one collection, choosing a suitable scope and `SharingStarted` policy. `catch` handles failures upstream of its position, so move operations whose exceptions it should handle before `catch`; cancellation should generally propagate. `conflate()` may replace pending values with newer ones when a collector is slow, so use it only when intermediate values can be skipped; buffering can decouple producer and consumer, but a finite buffer may fill. Finally, `stateIn()` with `WhileSubscribed()` will not start upstream until there is a subscriber, so a test that only calls `runCurrent()` can still see the initial value. Use `Eagerly` for immediate collection or start a collector when testing subscription-driven behavior.

### Source excerpt

Four well-known Kotlin Flow bugs that look correct at first, why they happen, and how to fix them

## The catch That Didn't: Kotlin Flow's Channel Trap

DevFeed: [The catch That Didn't: Kotlin Flow's Channel Trap](<https://devfeed.tech/articles/the-catch-that-didn-t-kotlin-flow-s-channel-trap-99317.md>)

Original publisher: [Read original article](<https://proandroiddev.com/the-catch-that-didnt-kotlin-flow-s-channel-trap-da1bbdea80f5?source=rss----c72404660798---4>)

Author: Ehab Elwan

Published: 2026-10-25T16:37:00Z

Content type: article

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Exception handling](<https://devfeed.tech/topics/exception-handling.md>), [Exception](<https://devfeed.tech/topics/exception.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [cancellation](<https://devfeed.tech/tags/cancellation.md>), [channel](<https://devfeed.tech/tags/channel.md>), [collector](<https://devfeed.tech/tags/collector.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [crash](<https://devfeed.tech/tags/crash.md>), [error](<https://devfeed.tech/tags/error.md>), [fallback](<https://devfeed.tech/tags/fallback.md>), [flow](<https://devfeed.tech/tags/flow.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.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>), [network](<https://devfeed.tech/tags/network.md>), [operator](<https://devfeed.tech/tags/operator.md>), [queue](<https://devfeed.tech/tags/queue.md>), [screen](<https://devfeed.tech/tags/screen.md>), [skip](<https://devfeed.tech/tags/skip.md>), [source](<https://devfeed.tech/tags/source.md>), [state](<https://devfeed.tech/tags/state.md>), [tools](<https://devfeed.tech/tags/tools.md>)

### AI overview

A `catch` placed after a channel-creating Kotlin Flow operator such as `flowOn` may miss an upstream error when downstream work is suspended: the source failure cancels collection, and `catch` can interpret that cancellation as a separate downstream failure. A queued value can also be lost when the source fails before it is collected. The excerpt reports reproductions on the JVM and Android with kotlinx.coroutines 1.11.0. Its main recommendation is to handle errors before the first channel-creating operator, in the layer that owns the source, and convert expected failures to values. Wrapping only a failing call in `try`/`catch` inside the flow builder is another option; omit `flowOn` when the builder is already main-safe. If the source cannot be changed, moving suspending work into `onEach` before `catch`, or using `conflate()` or `collectLatest` when skipped values or work are acceptable, can help with specific collector patterns. These workarounds do not restore queued values already lost; `collectLatest` also has a cancellation limitation. A `CoroutineExceptionHandler` may keep the app alive but does not ensure the `catch` block handles the error.

### Source excerpt

Why a catch after flowOn can skip your fallback or crash the app, and where to put it instead.TL;DR What breaks: a catch after flowOn, or after any other operator that creates a channel, can let the source's exception skip it, which crashes the app on Android, or drop a value still in the queue before the screen gets it. Reproduced on kotlinx.coroutines 1.11.0, on the JVM and on an Android device, with the pattern the official Android guide teaches. Who is affected: a collector that suspends per value (a network call or a snackbar per update), or an early stop such as first(). A collector that only writes UI state, like stateIn's, is safe from the crash. The fix: handle errors before the first operator that creates a channel, in the layer that owns the source. Move catch before flowOn (and before stateIn or shareIn) and turn the error into a value there, or wrap the one call that can fail in try/catch inside the flow builder. If every call is already main-safe, drop flowOn. Can't move it? If your collector suspends per value, move its work into onEach before catch, or use conflate() after catch or collectLatest { } when only the latest value matters. As a last resort, wrap the terminal call in try/catch, and ask the flow's owner to move catch. None of these saves a value already in the queue. Don't rely on a CoroutineExceptionHandler: the app survives, but your catch block almost never runs. How to spot it: the crash points at your own code above a catch that should have handled it, and its trace carries a Suppressed: cancellation. The rest of the article shows the crash, why it happens, and the ways out, with the runs behind each claim. Disclosure: drafted by me and refined with AI tools, which also helped create the tests.A crash your catch was written to prevent Take a chat app that shows a notification for each new message. The observer in this example has the same shape as Wire's: it posts the notifications, then marks the messages as notified, in a scope for t

## Hardening Coroutine Tests - Kevin Schildhorn

DevFeed: [Hardening Coroutine Tests - Kevin Schildhorn](<https://devfeed.tech/articles/hardening-coroutine-tests-kevin-schildhorn-98452.md>)

Original publisher: [Read original article](<https://touchlab.co/flake-free-flow-tests-pt1-coroutines>)

Published: 2026-10-23T18:00:00Z

Content type: article

Language: en

Sources: [Touchlab](<https://devfeed.tech/sources/touchlab-enterprise-mobile-innovation-development.md>)

Topics: [coroutine-testing](<https://devfeed.tech/topics/coroutine-testing.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Dependency injection](<https://devfeed.tech/topics/dependency-injection.md>), [scheduling](<https://devfeed.tech/topics/scheduling.md>)

Tags: [background-work](<https://devfeed.tech/tags/background-work.md>), [best-practices](<https://devfeed.tech/tags/best-practices.md>), [cache](<https://devfeed.tech/tags/cache.md>), [channel](<https://devfeed.tech/tags/channel.md>), [ci](<https://devfeed.tech/tags/ci.md>), [cleanup](<https://devfeed.tech/tags/cleanup.md>), [clock](<https://devfeed.tech/tags/clock.md>), [clocks](<https://devfeed.tech/tags/clocks.md>), [collector](<https://devfeed.tech/tags/collector.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutine-testing](<https://devfeed.tech/tags/coroutine-testing.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [coroutinescope](<https://devfeed.tech/tags/coroutinescope.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [delay](<https://devfeed.tech/tags/delay.md>), [dependency-injection](<https://devfeed.tech/tags/dependency-injection.md>), [dispatcher](<https://devfeed.tech/tags/dispatcher.md>), [emissions](<https://devfeed.tech/tags/emissions.md>), [flow](<https://devfeed.tech/tags/flow.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [scheduler](<https://devfeed.tech/tags/scheduler.md>), [tests](<https://devfeed.tech/tags/tests.md>), [turbine](<https://devfeed.tech/tags/turbine.md>)

### AI overview

Use StandardTestDispatcher with the runTest testScheduler, and inject dispatchers, scopes, and clocks so test work uses controlled virtual time. Drive scheduled work with runCurrent, advanceTimeBy, or advanceUntilIdle; inject TimeSource when code reads elapsed time or timestamps. Use backgroundScope for endless observers and settle it with runCurrent or advanceTimeBy; use a cancellable SupervisorJob scope for finite fire-and-forget work. Avoid parallel tests that set global Dispatchers.Main, and reset it after use. For necessary real-thread tests, keep most work virtual, synchronize on signals such as join or awaitItem rather than sleeps, use generous timeouts, cancel created scopes, and assert final values or invariant patterns instead of exact emission sequences. The supplied article excerpt reports substantial ordering variation and stale results in its repeated experiments, and warns that detached failures or shared state can cause false passes and cross-test flakiness.

### Source excerpt

Why coroutine tests flake, and the dispatcher and scheduler habits that stop it.

## Part 3: Kotlin Flows -- StateFlow & SharedFlow (The Billboards and Radio Towers)

DevFeed: [Part 3: Kotlin Flows -- StateFlow & SharedFlow (The Billboards and Radio Towers)](<https://devfeed.tech/articles/part-3-kotlin-flows-stateflow-sharedflow-the-billboards-and-radio-towers-91137.md>)

Original publisher: [Read original article](<https://proandroiddev.com/part-3-kotlin-flows-stateflow-sharedflow-the-billboards-and-radio-towers-e25e3f2d1060?source=rss----c72404660798---4>)

Author: Sandeep Kella

Published: 2026-10-20T16:43:06Z

Content type: article

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [state-management](<https://devfeed.tech/topics/state-management.md>), [Publish-subscribe pattern](<https://devfeed.tech/topics/pubsub.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [events](<https://devfeed.tech/tags/events.md>), [flow](<https://devfeed.tech/tags/flow.md>), [flow-state](<https://devfeed.tech/tags/flow-state.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-flow](<https://devfeed.tech/tags/kotlin-flow.md>), [radio](<https://devfeed.tech/tags/radio.md>), [score](<https://devfeed.tech/tags/score.md>), [sharedflow](<https://devfeed.tech/tags/sharedflow.md>), [stateflow](<https://devfeed.tech/tags/stateflow.md>)

### AI overview

StateFlow holds current state: it requires an initial value, gives new collectors the latest value, and ignores consecutive duplicates. The example keeps a MutableStateFlow private and exposes a read-only StateFlow to prevent UI code from changing ViewModel state. SharedFlow broadcasts events without requiring an initial value; replay can provide past values, while the default replay=0 drops events emitted when nobody is collecting. The article recommends StateFlow for state and SharedFlow for one-time events, and says cold flows can be shared in a ViewModel with stateIn or shareIn. SharingStarted.WhileSubscribed(5000) keeps upstream active for five seconds after the last collector leaves, allowing a quick reconnect without restarting it. It also contrasts StateFlow with LiveData, describing StateFlow as pure Kotlin and easier to use outside Android and in unit tests.

### Source excerpt

Hey again! So far, we've been talking about Cold Flows (our Air Compressor). Remember: a cold flow does absolutely nothing until someone pulls the trigger (.collect()). And if three different people pull the trigger, the compressor starts up three separate times, doing the exact same work from scratch. But what if you don't want that? What if you want one central source of truth that is always running, and multiple people can just look at it? Welcome to Hot Flows. In Android, we use two main types of Hot Flows: StateFlow and SharedFlow. The Breakdown: The Billboard vs. The Radio Tower 1. StateFlow: The Stadium Scoreboard (For STATE) Imagine you are at a football game. The scoreboard is a StateFlow. It must always have a value. The game starts at 0-0 (an initial state). If you go to the bathroom and come back, you just look at the scoreboard and immediately see the latest score. You don't care about every single point scored while you were in the bathroom; you just care about the current state. If the score is 7-0, and the scoreboard operator tries to update it to 7-0 again, nothing happens. It ignores duplicate consecutive values. // In your ViewModel // 1. Private mutable version (The guy operating the scoreboard) private val _uiState = MutableStateFlow<String>("Loading...") // 2. Public read-only version (The fans looking at the board) val uiState: StateFlow<String> = _uiState.asStateFlow() fun finishLoading() { _uiState.value = "Welcome to the App!" // Updates the board } 2. SharedFlow: The Radio Tower (For EVENTS) Imagine a radio station broadcasting a live concert. This is a SharedFlow. It does not need an initial value. If you tune your radio in at 5:00 PM, you hear whatever is playing right now. If you missed a song at 4:55 PM, it's gone forever (unless the station has a replay cache, which SharedFlow actually supports!). It is perfect for one-time events: showing a Toast message, playing a sound, or navigating to a new screen. You don't want to navigate to a

## Part 2: Kotlin Flows -- Mastering Operators (Valves, Filters, and T-Joints)

DevFeed: [Part 2: Kotlin Flows -- Mastering Operators (Valves, Filters, and T-Joints)](<https://devfeed.tech/articles/part-2-kotlin-flows-mastering-operators-valves-filters-and-t-joints-91136.md>)

Original publisher: [Read original article](<https://proandroiddev.com/part-2-kotlin-flows-mastering-operators-valves-filters-and-t-joints-f9d7a8ebd64c?source=rss----c72404660798---4>)

Author: Sandeep Kella

Published: 2026-10-20T16:42:42Z

Content type: article

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Exception handling](<https://devfeed.tech/topics/exception-handling.md>), [Exception](<https://devfeed.tech/topics/exception.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [collect](<https://devfeed.tech/tags/collect.md>), [data](<https://devfeed.tech/tags/data.md>), [exception](<https://devfeed.tech/tags/exception.md>), [fallback](<https://devfeed.tech/tags/fallback.md>), [filter](<https://devfeed.tech/tags/filter.md>), [flow](<https://devfeed.tech/tags/flow.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [map](<https://devfeed.tech/tags/map.md>), [network](<https://devfeed.tech/tags/network.md>), [ui](<https://devfeed.tech/tags/ui.md>)

### AI overview

Kotlin Flow operators transform, filter, and handle errors as items travel through a flow: `filter` keeps matching values, `map` converts each value, and `catch` can emit a fallback for upstream exceptions. Operators return wrapped flows; intermediate operators do not start execution, while terminal operators such as `collect` do. The article recommends keeping filtering and formatting outside UI collection code. It contrasts Flow's sequential per-item processing with List operators that create a new list in memory. Its interview examples note that `catch` does not handle errors thrown downstream in `collect`, and compare search strategies: `flatMapConcat` runs sequentially, `flatMapMerge` concurrently with potentially out-of-order results, and `flatMapLatest` cancels outdated work.

### Source excerpt

Hey again! In Part 1, we built our Air Compressor (the Flow) and pulled the trigger on our Spray Gun (the .collect() function) to start the air moving. But let's be real--if you just blast raw air straight out of a compressor, you're going to get moisture, dirt, and uneven pressure. To do a professional paint job, you need attachments on your hose. In Kotlin Flows, these attachments are called Operators. They intercept the data while it's traveling down the pipe, changing it before it ever reaches the UI (the spray gun). The Breakdown: Valves and Filters Let's look at the three most common attachments you'll put on your hose: 1. The Moisture Trap (filter) Sometimes the compressor spits out water droplets along with the air. You don't want water ruining your paint job. The filter operator acts like a screen--it only lets things pass if they meet a certain condition. // Only emit air bursts that are perfectly dry airFlow.filter { air -> air.isDry == true } 2. The Paint Mixer (map) Right now, you just have raw air. But you want blue paint. The map operator intercepts the raw air, mixes blue paint into it, and sends it further down the line. It literally transforms the data type from A to B. // Transforms RawAir into BluePaint airFlow.map { rawAir -> Paint(color = "Blue", pressure = rawAir.pressure) } 3. The Safety Release Valve (catch) What happens if the compressor explodes or a pipe bursts? In code, this is an Exception (like a network crash). If you don't have a safety valve, the explosion travels all the way to the spray gun and breaks it (your app crashes). The catch operator safely handles the explosion. airFlow .catch { exception -> println("Whoops! Pipe burst: $exception") emit(BackupAir()) // We can even emit a fallback value! } Diagrammatic Mental Model: [Compressor] ---> ( filter: keep dry ) ---> ( map: add paint ) ---> ( catch: safety ) ---> [Spray Gun] raw air dry air blue paint safe paint UI updatesUnder the Hood: What happens internally? Operators in Flow

## Finally The Official Way of Secure DataStore is Here!

DevFeed: [Finally The Official Way of Secure DataStore is Here!](<https://devfeed.tech/articles/finally-the-official-way-of-secure-datastore-is-here-91132.md>)

Original publisher: [Read original article](<https://proandroiddev.com/finally-the-official-way-of-secure-datastore-is-here-ae878f5eb457?source=rss----c72404660798---4>)

Author: Burak Karaduman

Published: 2026-10-20T16:18:09Z

Content type: tutorial

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [Cryptography](<https://devfeed.tech/topics/cryptography.md>), [Android Security](<https://devfeed.tech/topics/android-security.md>), [Secure token management](<https://devfeed.tech/topics/secure-token-management.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Exception](<https://devfeed.tech/topics/exception.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [backup](<https://devfeed.tech/tags/backup.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [data](<https://devfeed.tech/tags/data.md>), [encryption](<https://devfeed.tech/tags/encryption.md>), [error-handling](<https://devfeed.tech/tags/error-handling.md>), [flow](<https://devfeed.tech/tags/flow.md>), [jetpack-datastore](<https://devfeed.tech/tags/jetpack-datastore.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [mobile-app-security](<https://devfeed.tech/tags/mobile-app-security.md>)

### AI overview

The excerpt shows how `androidx.datastore:datastore-tink` can encrypt a typed DataStore through an `AeadSerializer` backed by Tink and an Android Keystore master key, replacing custom AES/GCM storage code. It explains that encryption protects copied files but not data read by the app itself. Decryption or deserialization failures become DataStore corruption; a handler can reset a session, while irreplaceable data needs another recovery plan. Because Android backups can restore the encrypted file and keyset without the device-bound master key, the excerpt advises excluding both from cloud and device-transfer backups. It also outlines migration from legacy encrypted preferences and notes that the library is alpha, key rotation is manual, and migration was unit-tested but not tested on an install retaining real legacy data.

### Source excerpt

Securing data has always been a concern since the early days of app development. Platforms do their best to protect user data, but there are always edge cases. Attackers may still reach sensitive data, even in encrypted form, and if they get the key, the protection is meaningless. So yes, encryption helps, but it is not magic. On Android we started with SharedPreferences. It was simple, widely used, and even had built in encryption through EncryptedSharedPreferences. Then Kotlin Flow and Coroutines arrived, apps reached a global audience, and codebases grew. We now needed async operations, thread safety, type safety, custom objects, proper error handling and reactive streams. SharedPreferences was not designed for that, and DataStore was introduced to solve it. But Google deprecated the Jetpack Security (security-crypto) library, and DataStore had no built in encryption, so most of us wrote our own. Now there is androidx.datastore:datastore-tink, added in DataStore 1.3.0-alpha07. In this post we build a small encrypted session store: a login screen that saves an email and a token, and a home screen that reads them. We also show what happens when decryption fails. The full sample project (with Hilt) is on GitHub: burkido/official-datastore-encryption-sample What encryption protects, and what it does not Encrypting a file protects it when someone gets the file but not your app, for example from a rooted phone, a raw copy of the device storage or a copied backup. It does not protect against code inside your own app, because that code can simply read the decrypted value from DataStore. Encryption is one layer of security. It is not the whole solution.How we did it before Our old setup was similar to the one in this article. A security class created an AES/GCM key in the Android Keystore and managed the IV manually: fun encryptData(keyAlias: String, text: String): Pair<ByteArray, ByteArray> { val secretKey = generateSecretKey(keyAlias) cipher.init(Cipher.ENCRYPT_MODE, se

## The Power of stateIn in ViewModel

DevFeed: [The Power of stateIn in ViewModel](<https://devfeed.tech/articles/the-power-of-statein-in-viewmodel-88053.md>)

Original publisher: [Read original article](<https://proandroiddev.com/the-power-of-statein-in-viewmodel-6a57864a8c5d?source=rss----c72404660798---4>)

Author: chanzmao

Published: 2026-10-15T17:11:34Z

Content type: article

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [state-management](<https://devfeed.tech/topics/state-management.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [declarative-ui](<https://devfeed.tech/tags/declarative-ui.md>), [flow](<https://devfeed.tech/tags/flow.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [mobile-app-development](<https://devfeed.tech/tags/mobile-app-development.md>), [software-architecture](<https://devfeed.tech/tags/software-architecture.md>), [state-management](<https://devfeed.tech/tags/state-management.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

For UI state derived from observable data, the excerpt recommends expressing dependencies with Kotlin Flow operators such as `map` and `combine`, then using `stateIn` to expose the result as a `StateFlow`. Its examples derive a list screen's state from repository items and a mutable search query, avoiding manual copying and synchronization; `MutableStateFlow` remains appropriate for inputs such as the query. Explicit commands still fit one-time work, refreshes, and user actions. `SharingStarted.WhileSubscribed(5_000)` starts collection with a subscriber and stops it five seconds after the last unsubscribes, but does not itself guarantee a network request will repeat; `stateIn` shares and retains upstream emissions rather than fetching data.

### Source excerpt

Building Declarative UI State with Kotlin Flow. Image created by AI In Jetpack Compose, we often see ViewModels that manually manage UI state, call load() from init, and update several properties whenever data changes. This approach works, but it can introduce unnecessary boilerplate. As an application grows, keeping multiple pieces of state synchronized becomes increasingly difficult. Kotlin Flow offers a more declarative alternative. By combining Flow operators with stateIn, we can define how UI state is derived from its inputs and let the stream handle updates. The Hidden Cost of Manual State Updates Consider a typical ViewModel: class MyViewModel( private val repository: MyRepository ) : ViewModel() { private val _uiState = MutableStateFlow(UiState()) val uiState = _uiState.asStateFlow() init { load() } private fun load() { viewModelScope.launch { val items = repository.loadItems() _uiState.update { it.copy(items = items) } } } } This is a perfectly valid implementation. It is easy to understand, especially when loading data involves a one-time operation. However, the ViewModel is responsible for several things: Starting the initial load. Updating the state after loading. Preserving unrelated state fields. Keeping the UI state consistent as more inputs are added. As the screen becomes more complex, these responsibilities can lead to repetitive state-management code. What if the repository already exposes a Flow of items? Do we still need to collect it manually and copy every update into another state holder? Often, we do not. Do We Really Need to Call load()? A common Compose pattern is: LaunchedEffect(Unit) { viewModel.load() } Another option is to call load() from the ViewModel's init block. Both approaches have legitimate uses. A user-triggered refresh, a one-time operation, or a request that depends on a specific event may need an explicit command. But when the screen simply reflects data that is already represented by a Flow, manually initiating and synchro

## Everything Is a Source -- Part 1

DevFeed: [Everything Is a Source -- Part 1](<https://devfeed.tech/articles/everything-is-a-source-part-1-88050.md>)

Original publisher: [Read original article](<https://proandroiddev.com/everything-is-a-source-part-1-0155cfd84c4d?source=rss----c72404660798---4>)

Author: Damian Petla | Tilt

Published: 2026-10-15T16:42:03Z

Content type: article

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [business logic](<https://devfeed.tech/topics/business-logic.md>), [Functional programming](<https://devfeed.tech/topics/functional-programming.md>), [Grafana](<https://devfeed.tech/topics/grafana.md>), [OpenTelemetry](<https://devfeed.tech/topics/opentelemetry.md>)

Tags: [ai-coding-agents](<https://devfeed.tech/tags/ai-coding-agents.md>), [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [business-logic](<https://devfeed.tech/tags/business-logic.md>), [caching](<https://devfeed.tech/tags/caching.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [error-handling](<https://devfeed.tech/tags/error-handling.md>), [flow](<https://devfeed.tech/tags/flow.md>), [framework](<https://devfeed.tech/tags/framework.md>), [ios](<https://devfeed.tech/tags/ios.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [networking](<https://devfeed.tech/tags/networking.md>), [pipeline](<https://devfeed.tech/tags/pipeline.md>), [repository](<https://devfeed.tech/tags/repository.md>), [software-architecture](<https://devfeed.tech/tags/software-architecture.md>)

### AI overview

Tilt replaced hand-written coroutine plumbing and 11 Apollo-specific combine overloads with a roughly 1,600-line Kotlin pipeline built around `PipelineSource<T>`, which wraps `Flow<TiltResult<T>>`. A single `source(...)` factory accepts Apollo calls, flows, values, or existing results; typed combine functions short-circuit on failure, and `build()` and `buildOnce()` distinguish long-lived streams from one-shot reads. Failures propagate by default, while explicit fallbacks make deliberate degradation visible; the home-feed example logs, times out, and falls back for optional settings while allowing feed failures through. The framework also exposed a migration tradeoff: replacing an auction product cache with a stream suppressed unrelated auction updates and refetched all products when IDs changed, so the author restored a plain cache that hands out sources. The excerpt says the shared module has over 50 files using the pattern and that older code is migrating function by function. Its closing section describes tracing as planned for Part 2, not covered here.

### Source excerpt

Part 1 of 2: how a small, home-grown data pipeline became the backbone of Tilt's Kotlin Multiplatform data layer. Part 2 covers what it unlocked: OpenTelemetry tracing with Grafana. At Tilt, the Android and iOS apps share one Kotlin Multiplatform module that owns networking, caching and business logic. A year ago, every repository function in it was a small, hand-rolled piece of coroutine plumbing. Today almost every new one is a single expression that reads like a sentence: source(apolloClient.query(ProductQuery(id))) .transform { converter.toDomain(it) } .buildOnce() This article is about the roughly 1,600 lines of Kotlin behind that expression: why I built them instead of adopting a library, the first design I threw away, and the one idea that survived every refactor: everything is a source. There is also a twist I did not plan for. I built the framework as guardrails for developers who did not know Flows well. It turned out to be exactly the guardrails AI coding agents needed too. The problem: more contributors, less Flow experience In late 2025, iOS developers started contributing to the shared module. That was the point of Kotlin Multiplatform, and it was great. But coroutines and Flows have plenty of sharp edges: when a flow completes, what flatMapLatest cancels, where an exception ends up, why you must never swallow a CancellationException. These are not obvious if Swift is your daily language. The bigger issue was not knowledge of Flows. It was error handling that was quietly skipped. A typical repository function looked like this: return flow { emit(executeDataCatching(apolloClient.query(BundlesConfigQuery(roomId))) { /* map */ }) }.flatMapLatest { configResult -> if (configResult.isSuccess) { val config = configResult.getOrThrow() if (config.sellerId != null && config.enabled) { combineTiltResult( apolloClient.subscription(BundlesSubscription(config.sellerId)), apolloClient.subscription(AddressSubscription(roomId)), ) { bundles, address -> converter.toDom

## Part 1: Kotlin Flows -- The Air Compressor of Android (Fundamentals & Cold Streams)

DevFeed: [Part 1: Kotlin Flows -- The Air Compressor of Android (Fundamentals & Cold Streams)](<https://devfeed.tech/articles/part-1-kotlin-flows-the-air-compressor-of-android-fundamentals-cold-streams-88051.md>)

Original publisher: [Read original article](<https://proandroiddev.com/part-1-kotlin-flows-the-air-compressor-of-android-fundamentals-cold-streams-7ae94471c1d7?source=rss----c72404660798---4>)

Author: Sandeep Kella

Published: 2026-10-15T16:34:19Z

Content type: tutorial

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

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

Tags: [android](<https://devfeed.tech/tags/android.md>), [backpressure](<https://devfeed.tech/tags/backpressure.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [database](<https://devfeed.tech/tags/database.md>), [delay](<https://devfeed.tech/tags/delay.md>), [flow](<https://devfeed.tech/tags/flow.md>), [generate](<https://devfeed.tech/tags/generate.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-flow](<https://devfeed.tech/tags/kotlin-flow.md>), [network](<https://devfeed.tech/tags/network.md>), [stream](<https://devfeed.tech/tags/stream.md>), [streams](<https://devfeed.tech/tags/streams.md>), [timer](<https://devfeed.tech/tags/timer.md>), [tool](<https://devfeed.tech/tags/tool.md>)

### AI overview

This tutorial introduces Kotlin Flow through an air-compressor analogy, explaining cold streams, collection, operators, cancellation, and backpressure. It also compares Flow with lists, LiveData, and RxJava, and discusses coroutine context and flowOn.

### Source excerpt

Hey! So you want to learn Kotlin Flows? Grab a seat. I know the official documentation can sometimes feel like reading a microwave manual, but I promise you, once you get the mental model right, Flows are going to be your best friend. Forget about the code for a second. Let's talk about air. The Breakdown: The Air Compressor Analogy Imagine you are painting a car using an Air Compressor and a Spray Gun. The Producer (The Compressor): This is where the air is generated. In Kotlin, this is your database, your network call, or a timer. The Flow (The Hose): This is the pipe connecting the compressor to your tool. The Operators (Valves & Filters): Maybe you have a moisture filter on the hose, or a pressure regulator. It modifies the air before it reaches you. The Consumer / Collector (The Spray Gun): This is your Android UI. Here is the most important concept to understand about a standard Kotlin Flow: It is a COLD stream. What does "Cold" mean? Imagine your air compressor is completely turned off and silent. It will not generate a single ounce of air until you pull the trigger on the spray gun. The moment you pull the trigger (in Kotlin, we call this .collect()), the compressor kicks on, air pushes through the filters, and paint comes out. When you let go of the trigger (cancel the coroutine), the whole system shuts down instantly. Diagrammatic Mental Model: Plaintext [Air Compressor] ---> (Pressure Valve) ---> (Moisture Filter) ---> [Spray Gun] (Producer) (Operator: map) (Operator: filter) (Collector) Status: DEAD SILENT until someone pulls the trigger on the Spray Gun. Let's look at how this looks in code: Kotlin // 1. The Compressor (Producer) val airFlow = flow { println("Compressor turned on!") emit("Air Burst 1") delay(1000) // Takes a second to build pressure emit("Air Burst 2") } // 2. The Trigger (Collector) // If we don't write this code below, the "Compressor turned on!" is NEVER printed. coroutineScope.launch { airFlow.collect { air -> println("Spray gun rec

## The Evolution of Flow Collection in Jetpack Compose

DevFeed: [The Evolution of Flow Collection in Jetpack Compose](<https://devfeed.tech/articles/the-evolution-of-flow-collection-in-jetpack-compose-85772.md>)

Original publisher: [Read original article](<https://proandroiddev.com/the-evolution-of-flow-collection-in-jetpack-compose-e93416a9d52d?source=rss----c72404660798---4>)

Author: chanzmao

Published: 2026-10-13T00:04:28Z

Content type: article

Language: en

Sources: [ProAndroidDev](<https://devfeed.tech/sources/proandroiddev-medium.md>)

Topics: [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>), [Boilerplate](<https://devfeed.tech/topics/boilerplate.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-architecture](<https://devfeed.tech/tags/android-architecture.md>), [android-compose](<https://devfeed.tech/tags/android-compose.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [api](<https://devfeed.tech/tags/api.md>), [app-architecture](<https://devfeed.tech/tags/app-architecture.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [background](<https://devfeed.tech/tags/background.md>), [collection](<https://devfeed.tech/tags/collection.md>), [compose](<https://devfeed.tech/tags/compose.md>), [composition](<https://devfeed.tech/tags/composition.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [evolution](<https://devfeed.tech/tags/evolution.md>), [flow](<https://devfeed.tech/tags/flow.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [mobile-app-development](<https://devfeed.tech/tags/mobile-app-development.md>), [state](<https://devfeed.tech/tags/state.md>), [ui](<https://devfeed.tech/tags/ui.md>), [upstream](<https://devfeed.tech/tags/upstream.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

`collectAsStateWithLifecycle()` packages lifecycle-aware Flow collection into a concise Compose API: collection runs while the lifecycle is active and stops below the chosen state. Earlier options have tradeoffs: `collectAsState()` may keep collecting while the composition remains active; `launchWhenStarted()` can suspend collection while upstream work continues; `repeatOnLifecycle()` cancels and restarts its block but requires more code; and `flowWithLifecycle()` still needs Compose state conversion and an initial value for a regular Flow. Stopping UI collection does not necessarily stop upstream work or refresh data. For example, `stateIn` with `SharingStarted.WhileSubscribed(5_000)` can keep upstream active for five seconds after the last subscriber; later restart behavior depends on the source Flow. A cold HTTP Flow may fetch again, while a Room Flow resuming observation does not necessarily make a network request.

### Source excerpt

From basic state collection to lifecycle-aware UI updates Image created by AI When collecting a Flow in Jetpack Compose, the code can be as simple as this: val uiState by viewModel.uiState.collectAsState() But Android applications have a lifecycle. When an app moves to the background, should the UI continue collecting updates? What happens when the user returns? Over the years, Android developers have used several approaches to handle these questions. Understanding how they evolved helps us choose the right API without adding unnecessary code. Let's walk through the key changes, from collectAsState()to collectAsStateWithLifecycle(). 1. Compose 1.0: collectAsState()July 2021 Jetpack Compose 1.0 introduced collectAsState() as a straightforward way to convert a Flow into Compose State. val uiState by viewModel.uiState.collectAsState() Whenever the Flow emits a new value, Compose updates the state and recomposes the relevant UI. The code is simple, but there is an important distinction: collectAsState() does not automatically stop collection when the Android lifecycle falls below STARTED. For example, when an Activity moves to the background, collection can continue as long as the composition remains active. This isn't necessarily a problem for every Flow. However, if the upstream Flow performs expensive work or maintains an active connection, continuing to collect while the UI is not visible may be undesirable. 2. Lifecycle 2.4.0: launchWhenStarted() and repeatOnLifecycle()October 2021 Before lifecycle-aware collection became a simple Compose API, developers often managed the lifecycle manually. One approach was launchWhenStarted(): lifecycleOwner.lifecycleScope.launch { lifecycleOwner.lifecycle.launchWhenStarted { viewModel.uiState.collect { state -> // Handle state } } } This approach tied execution to the lifecycle, but it had a significant drawback: when the lifecycle stopped, the coroutine could be suspended rather than cancelled. Upstream work could continue unne

## Learn Modern Kotlin

DevFeed: [Learn Modern Kotlin](<https://devfeed.tech/articles/learn-modern-kotlin-64150.md>)

Original publisher: [Read original article](<https://www.freecodecamp.org/news/learn-modern-kotlin/>)

Author: Beau Carnes

Published: 2026-10-02T15:23:58Z

Content type: release

Language: en

Sources: [Free Code Camp](<https://devfeed.tech/sources/freecodecamp-programming-tutorials-python-javascript-git-more.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [suspend function](<https://devfeed.tech/topics/suspend-function.md>), [IntelliJ IDEA](<https://devfeed.tech/topics/intellij-idea.md>), [compose-for-desktop](<https://devfeed.tech/topics/compose-for-desktop.md>)

Tags: [android-development](<https://devfeed.tech/tags/android-development.md>), [applications](<https://devfeed.tech/tags/applications.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [flow](<https://devfeed.tech/tags/flow.md>), [intellij-idea](<https://devfeed.tech/tags/intellij-idea.md>), [jvm](<https://devfeed.tech/tags/jvm.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [learn](<https://devfeed.tech/tags/learn.md>), [programming](<https://devfeed.tech/tags/programming.md>), [reactive-streams](<https://devfeed.tech/tags/reactive-streams.md>), [youtube](<https://devfeed.tech/tags/youtube.md>)

### AI overview

A free 10-hour Kotlin course on the freeCodeCamp.org YouTube channel covers Kotlin fundamentals, object-oriented programming, generics, coroutines, and flows. It targets Android development, backend services, and cross-platform applications.

### Source excerpt

We just published a comprehensive, free Kotlin course on the freeCodeCamp.org YouTube channel. Whether you're targeting Android development, scalable backend services, or cross-platform applications,

## Improved runCatching

DevFeed: [Improved runCatching](<https://devfeed.tech/articles/improved-runcatching-85538.md>)

Original publisher: [Read original article](<https://kt.academy/article/runCatching>)

Published: 2026-09-28T00:00:00Z

Content type: tutorial

Language: en

Sources: [Kt. Academy](<https://devfeed.tech/sources/kt-academy.md>)

Topics: [Error Handling](<https://devfeed.tech/topics/error-handling.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [suspend function](<https://devfeed.tech/topics/suspend-function.md>)

Tags: [android-development](<https://devfeed.tech/tags/android-development.md>), [cancellation](<https://devfeed.tech/tags/cancellation.md>), [error](<https://devfeed.tech/tags/error.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

### AI overview

The article proposes a safer alternative to Kotlin's runCatching by catching Exception instead of Throwable and rethrowing CancellationException and InterruptedException so cancellation signals are preserved. It also notes that adding a contract could help the compiler reason about uses, and suggests naming the replacement runCatchingCancellable.

### Source excerpt

How to correct runCatching from Kotlin stdlib

## Using the new Google Gen AI SDK for Kotlin

DevFeed: [Using the new Google Gen AI SDK for Kotlin](<https://devfeed.tech/articles/using-the-new-google-gen-ai-sdk-for-kotlin-25196.md>)

Original publisher: [Read original article](<https://johnoreilly.dev/posts/genai-kotlin-sdk/>)

Published: 2026-09-04T23:00:00Z

Content type: article

Language: en

Sources: [John O'Reilly](<https://devfeed.tech/sources/john-o-reilly.md>)

Topics: [SDK](<https://devfeed.tech/topics/sdk.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Firebase](<https://devfeed.tech/topics/firebase.md>), [firebase-ai-logic](<https://devfeed.tech/topics/firebase-ai-logic.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [ai-sdk](<https://devfeed.tech/tags/ai-sdk.md>), [apis](<https://devfeed.tech/tags/apis.md>), [base64](<https://devfeed.tech/tags/base64.md>), [basketball](<https://devfeed.tech/tags/basketball.md>), [client](<https://devfeed.tech/tags/client.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [firebase](<https://devfeed.tech/tags/firebase.md>), [gemini](<https://devfeed.tech/tags/gemini.md>), [gen-ai](<https://devfeed.tech/tags/gen-ai.md>), [google](<https://devfeed.tech/tags/google.md>), [koog](<https://devfeed.tech/tags/koog.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [library](<https://devfeed.tech/tags/library.md>), [rest](<https://devfeed.tech/tags/rest.md>), [sdk](<https://devfeed.tech/tags/sdk.md>), [sdks](<https://devfeed.tech/tags/sdks.md>)

### AI overview

Google's Gen AI SDK for Kotlin replaces FormAI's hand-built Gemini REST calls with an idiomatic client built around coroutines and Flow. The JVM tool processes video clips with two requests: a plain-text coaching critique and schema-constrained JSON containing timestamps for four swing or movement moments. The SDK accepts video bytes directly and handles base64 encoding; its text convenience method joins text parts from the first candidate while skipping parts marked as thinking. The excerpt says the client can read an API key from an environment variable or receive one explicitly, and that the tool passes a request timeout. It also notes that adding the SDK removes the module's separate HTTP client and mirrored request/response data classes. The excerpt cuts off during the structured-output explanation, so further implementation details are unavailable.

### Source excerpt

Google have just released version 1.0 of the Gen AI SDK for Kotlin, an idiomatic Kotlin client for the Gemini APIs. Up to now, calling Gemini from Kotlin has generally meant use of one of the Firebase SDKs, a community wrapper, an agent framework like Koog, or (as in the code below) just talking to the REST endpoint yourself. This is Google's own Kotlin library for it, built around coroutines and Flow.

## Bring your KMP library to NuGet

DevFeed: [Bring your KMP library to NuGet](<https://devfeed.tech/articles/bring-your-kmp-library-to-nuget-25915.md>)

Original publisher: [Read original article](<https://proandroiddev.com/bring-your-kmp-library-to-nuget-02e1131a4707?source=rss-43bae76e8f81------2>)

Author: Isuru Rajapakse

Published: 2026-07-19T13:17:14Z

Content type: release

Language: en

Sources: [Isuru Rajapakse](<https://devfeed.tech/sources/stories-by-isuru-rajapakse-on-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [NuGet](<https://devfeed.tech/topics/nuget.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [Boilerplate](<https://devfeed.tech/topics/boilerplate.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>)

Tags: [abi](<https://devfeed.tech/tags/abi.md>), [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [coroutines-flow](<https://devfeed.tech/tags/coroutines-flow.md>), [dotnet](<https://devfeed.tech/tags/dotnet.md>), [ffi](<https://devfeed.tech/tags/ffi.md>), [flow](<https://devfeed.tech/tags/flow.md>), [generics](<https://devfeed.tech/tags/generics.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [gradle-plugin](<https://devfeed.tech/tags/gradle-plugin.md>), [kmp](<https://devfeed.tech/tags/kmp.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [kotlin-native](<https://devfeed.tech/tags/kotlin-native.md>), [library](<https://devfeed.tech/tags/library.md>), [net](<https://devfeed.tech/tags/net.md>), [nuget](<https://devfeed.tech/tags/nuget.md>), [nuget-package](<https://devfeed.tech/tags/nuget-package.md>)

### AI overview

kotlin-native-nuget is an experimental Gradle plugin for packaging Kotlin/Native libraries as NuGet packages with generated C# bindings, and for generating Kotlin bindings to selected C# NuGet APIs. For Kotlin-to-C#, it processes the public API at build time, generates an Interop.cs file, compiles target-specific shared libraries, and packages both for .NET; consumers need no extra tooling. The article shows mappings for classes, enums, data classes, collections, generics, nullable values, interfaces, suspend functions, Flow, and cancellation. Runtime calls cross the C ABI through P/Invoke. In the reverse direction, developers select C# namespaces and can use generated Kotlin-idiomatic bindings. The author cautions that the plugin is 0.x and experimental, reverse support is still developing, and some Kotlin constructs are unsupported.

### Source excerpt

with kotlin-native-nuget plugin, you can bring your Kotlin to C# idiomaticallyhttps://medium.com/media/0f185efc67390bbf440bfc33f5675f42/href A little while ago, I gave a talk where I tried to take a library written in Kotlin and hand it to a .NET developer as a NuGet package. By hand. It is 30 minutes of me walking into every brick wall you can imagine - the C ABI, marshalling strings, keeping objects alive across the boundary, making any of it look like C# a human would actually want to use. Introducing kotlin-native-nuget 🪟kotlin-native-nuget plugin auto-binds your kotlin api into C# I turned all of that into a plugin, so you don't have to hit a single one of those walls. You write Kotlin, and out the other side comes a NuGet package with a proper, idiomatic C# API: classes, enums, data classes, coroutines, Flow, generics, interfaces, the works. No FFI boilerplate, no hand-written [DllImport], no "here's a C header, good luck". Your friends over in .NET just `dotnet add package` it and use it like it was C# all along. It's called kotlin-native-nuget, and it's a Gradle plugin. Here's the pitch: GitHub - xxfast/kotlin-native-nuget: A plugin that packages a Kotlin/Native library as a NuGet package with generated C# bindings, and consumes C# NuGet packages from Kotlin The pitch 🛗plugins { kotlin("multiplatform") id("io.github.xxfast.kotlin.native.nuget") version "<version>" } kotlin { mingwX64 { binaries { sharedLib { baseName = "mycatlib" } } } macosArm64 { binaries { sharedLib { baseName = "mycatlib" } } } } nuget { publish { packageId = "MyCatLib" version = "1.0.0" authors = "yourname" description = "My Kotlin/Native library" rootPackage = "com.example.cats" } } That's it. Add the plugin, point it at your native targets, and run the publish task. Out pops a .nupkg. Why though? 🤔 It's a fair question. I got it a lot (even on that talk) Kotlin Multiplatform already reaches an absurd number of places: the JVM, Android, iOS, JS, Wasm, and native desktop. But there's th

## Practical Kotlin Deep Dive: Master Kotlin Internals and Ace Your Next Technical Interview

DevFeed: [Practical Kotlin Deep Dive: Master Kotlin Internals and Ace Your Next Technical Interview](<https://devfeed.tech/articles/practical-kotlin-deep-dive-master-kotlin-internals-and-ace-your-next-technical-interview-25926.md>)

Original publisher: [Read original article](<https://skydoves.medium.com/practical-kotlin-deep-dive-master-kotlin-internals-and-ace-your-next-technical-interview-33ff30f91493?source=rss-9bb203a4ab2e------2>)

Author: Jaewoong Eum

Published: 2026-02-18T03:55:53Z

Content type: article

Language: en

Sources: [Jaewoong Eum](<https://devfeed.tech/sources/stories-by-jaewoong-eum-on-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Learning](<https://devfeed.tech/topics/learning.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [runBlocking](<https://devfeed.tech/topics/runblocking.md>), [software-development](<https://devfeed.tech/topics/software-development.md>), [scope function](<https://devfeed.tech/topics/scope-function.md>), [Safe-Call Operator](<https://devfeed.tech/topics/safe-call-operator.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [book](<https://devfeed.tech/tags/book.md>), [bytecode](<https://devfeed.tech/tags/bytecode.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [course](<https://devfeed.tech/tags/course.md>), [data-class](<https://devfeed.tech/tags/data-class.md>), [debugging](<https://devfeed.tech/tags/debugging.md>), [deep-dive](<https://devfeed.tech/tags/deep-dive.md>), [insights](<https://devfeed.tech/tags/insights.md>), [interactive](<https://devfeed.tech/tags/interactive.md>), [internals](<https://devfeed.tech/tags/internals.md>), [interview](<https://devfeed.tech/tags/interview.md>), [keep](<https://devfeed.tech/tags/keep.md>), [knowledge](<https://devfeed.tech/tags/knowledge.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [lambda](<https://devfeed.tech/tags/lambda.md>), [language](<https://devfeed.tech/tags/language.md>), [lazy](<https://devfeed.tech/tags/lazy.md>), [performance](<https://devfeed.tech/tags/performance.md>), [programming](<https://devfeed.tech/tags/programming.md>), [technical-interview](<https://devfeed.tech/tags/technical-interview.md>)

### AI overview

Practical Kotlin Deep Dive teaches Kotlin internals through bytecode, compiler references, and KEEP proposals across 70 topics in six chapters. The excerpt highlights practical mechanisms: lambda objects explain the role of `inline`; coroutine cancellation exceptions can be swallowed by broad catches; and `kotlinx-serialization` generates serializers at compile time rather than relying on reflection. It also contrasts KAPT, which generates Java stubs for annotation processors, with KSP, which reads Kotlin symbols directly and is described as at least twice as fast in many projects. The companion course adds runnable playgrounds and 158 quizzes; the book and course share the same topic coverage, while the course includes practice and a completion certificate. These points describe the material presented in the supplied excerpt.

### Source excerpt

Most Kotlin developers can write a data class, launch a coroutine, or use lazy without thinking twice. These features work, the code compiles, and the app runs. But there is a gap between knowing how to use Kotlin and understanding what the compiler actually does with your code. That gap is where performance intuition, debugging skill, and technical interview confidence come from. Practical Kotlin Deep Dive is a book designed to close that gap, covering 70 Kotlin topics across 492 pages with bytecode decompilations, compiler source code references, and KEEP proposal analysis that reveal the machinery behind every feature you use daily. In this article, you'll explore what the book and its companion course cover, walking through each of the six chapters with examples of the insights you'll find inside. You'll see how the book approaches topics differently from typical Kotlin resources, what the "Pro Tips for Mastery" sections reveal about internal mechanisms, and how the interactive course format turns that knowledge into verified understanding through Code Playgrounds and 158 quiz questions. Beyond the syntax: Why internals matter Knowing that lazy caches a value on first access is useful. Knowing that the default lazy implementation uses double checked locking with a synchronized block, and that you can switch to a lock free compareAndSet strategy by passing LazyThreadSafetyMode.PUBLICATION, is the difference between using a feature and making informed decisions about it. The same applies across the language. Understanding that every lambda passed to a higher order function creates a Function object on the heap explains why inline exists. Seeing a data class decompiled into seven generated methods explains what the compiler is doing on your behalf. This is the approach Practical Kotlin Deep Dive takes throughout. Rather than describing what Kotlin features do, it examines how they work internally, what bytecode they produce, what design trade-offs the language desi

## Scalable API Response Handling Across Multi-Layered Architectures with Sandwich

DevFeed: [Scalable API Response Handling Across Multi-Layered Architectures with Sandwich](<https://devfeed.tech/articles/scalable-api-response-handling-across-multi-layered-architectures-with-sandwich-25924.md>)

Original publisher: [Read original article](<https://proandroiddev.com/scalable-api-response-handling-across-multi-layered-architectures-with-sandwich-39ab02ae8c90?source=rss-9bb203a4ab2e------2>)

Author: Jaewoong Eum

Published: 2026-02-08T06:25:14Z

Content type: article

Language: en

Sources: [Jaewoong Eum](<https://devfeed.tech/sources/stories-by-jaewoong-eum-on-medium.md>)

Topics: [Error Handling](<https://devfeed.tech/topics/error-handling.md>), [API](<https://devfeed.tech/topics/api.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Exception handling](<https://devfeed.tech/topics/exception-handling.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>)

Tags: [advanced](<https://devfeed.tech/tags/advanced.md>), [all](<https://devfeed.tech/tags/all.md>), [also](<https://devfeed.tech/tags/also.md>), [android](<https://devfeed.tech/tags/android.md>), [api](<https://devfeed.tech/tags/api.md>), [apis](<https://devfeed.tech/tags/apis.md>), [applications](<https://devfeed.tech/tags/applications.md>), [approach](<https://devfeed.tech/tags/approach.md>), [architectures](<https://devfeed.tech/tags/architectures.md>), [article](<https://devfeed.tech/tags/article.md>), [basic](<https://devfeed.tech/tags/basic.md>), [blocks](<https://devfeed.tech/tags/blocks.md>), [body](<https://devfeed.tech/tags/body.md>), [boilerplate](<https://devfeed.tech/tags/boilerplate.md>), [but](<https://devfeed.tech/tags/but.md>), [cases](<https://devfeed.tech/tags/cases.md>), [challenge](<https://devfeed.tech/tags/challenge.md>), [code](<https://devfeed.tech/tags/code.md>), [handling](<https://devfeed.tech/tags/handling.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [networking](<https://devfeed.tech/tags/networking.md>), [retrofit](<https://devfeed.tech/tags/retrofit.md>), [with](<https://devfeed.tech/tags/with.md>)

### AI overview

Sandwich preserves API outcome context across Android architecture layers by wrapping calls in a sealed `ApiResponse` with distinct success, HTTP error, and client exception cases. This avoids the ambiguity and repeated `try-catch` blocks that arise when data sources return fallback values such as empty lists. Retrofit integrates through `ApiResponseCallAdapterFactory`; Ktor uses `apiResponseOf`, and Ktorfit uses `ApiResponseConverterFactory`, yielding the same response type. The text describes handlers and transformations for mapping, sequential dependent requests, recovery, validation, filtering, and combining responses. `zip` returns the first failure if either response fails, while paginated `merge` can either fail on any page or retain successful pages and ignore failures. Flow and suspend variants support asynchronous work in handlers. The overview is based on the supplied article text.

### Source excerpt

Unsplash@picoftasty Modern Android applications commonly adopt multi-layered architectures such as MVVM or MVI, where data flows through distinct layers: a data source, a repository, and a ViewModel (or presentation layer). Each layer has a specific responsibility, and network responses must propagate through all of them before reaching the UI. While this separation produces clean, testable code, it introduces a real challenge: how do you handle API responses, including errors and exceptions, as they cross each layer boundary? Most developers solve this by wrapping API calls in try-catch blocks and returning fallback values. This works for small projects, but as the number of API calls grows, the approach creates ambiguous results, scattered boilerplate, and lost context that downstream layers need. You end up with ViewModels that cannot tell whether an empty list means "no data" or "network failure," repositories that swallow important error details, and data sources that repeat the same error handling pattern dozens of times. In this article, you'll explore the problems that emerge when handling Retrofit API calls across layered architectures, why conventional approaches break down at scale, and how Sandwich provides a type safe, composable solution that simplifies response handling from the network layer all the way to the UI. You'll also walk through the full set of Sandwich APIs, from basic response handling to advanced patterns like sequential composition, response merging, global error mapping, and Flow integration, each with real world use cases that show when and why you would reach for them. Retrofit API calls with coroutines Most Android projects use Retrofit with Kotlin coroutines for network communication. A typical service interface looks like this: https://medium.com/media/ebcba33386d664d1cf69a89234d2e22a/href The service returns a List<Poster> directly. Retrofit deserializes the JSON response body and gives you the data. This works perfectly when the

## Android ViewModel Data Loading: Best Practices and Flow-Based Architecture

DevFeed: [Android ViewModel Data Loading: Best Practices and Flow-Based Architecture](<https://devfeed.tech/articles/android-viewmodel-data-loading-best-practices-and-flow-based-architecture-22967.md>)

Original publisher: [Read original article](<https://funkymuse.github.io/posts/properly-load-data/>)

Author: FunkyMuse

Published: 2025-08-28T23:11:00Z

Content type: opinion

Language: en

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

Topics: [Android](<https://devfeed.tech/topics/android.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [software-development](<https://devfeed.tech/topics/software-development.md>), [MVVM](<https://devfeed.tech/topics/mvvm.md>), [Jetpack](<https://devfeed.tech/topics/jetpack.md>), [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [User Interfaces](<https://devfeed.tech/topics/user-interfaces.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [antipatterns](<https://devfeed.tech/tags/antipatterns.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [best-practices](<https://devfeed.tech/tags/best-practices.md>), [data](<https://devfeed.tech/tags/data.md>), [flow](<https://devfeed.tech/tags/flow.md>), [loading](<https://devfeed.tech/tags/loading.md>), [mvi](<https://devfeed.tech/tags/mvi.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

The article argues that loading data in a ViewModel's `init {}` block can cause stale data on backstack returns, dispatcher timing races with Compose, and harder tests. It proposes turning cold flows into hot `StateFlow`s with sharing strategies, refresh triggers, `distinctUntilChanged()`, and optional cached state to control when data reloads. A five-second timeout is offered as an example for retaining data across brief configuration changes while refreshing when collectors return later; the author also suggests adjusting it for real-time needs. Reusable ViewModel abstractions can reduce boilerplate, though the described extension pattern does not cover complex flow chaining. The author presents this as an opinionated approach for many common cases, with tradeoffs such as added state mapping complexity, and notes that it may not fit every application.

### Source excerpt

Architecture discussions in Android development often spark passionate debates--sometimes garnering both praise and criticism. Writing about these topics isn't easy, but that's what makes it worthwhile. This article presents my opinionated perspective on data loading patterns, refined through experience and recovery from recent surgeries (one recovery is still in progress). Consider this a sna...

## Collecting items from the Flow in chunks💦

DevFeed: [Collecting items from the Flow in chunks💦](<https://devfeed.tech/articles/collecting-items-from-the-flow-in-chunks-25706.md>)

Original publisher: [Read original article](<https://blog.shreyaspatil.dev/collecting-items-from-the-flow-in-chunks/>)

Author: Shreyas Patil

Published: 2023-10-23T04:46:23Z

Content type: tutorial

Language: en

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

Topics: [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Streaming](<https://devfeed.tech/topics/streaming.md>), [batch insert](<https://devfeed.tech/topics/batch-insert.md>)

Tags: [analytics](<https://devfeed.tech/tags/analytics.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [database](<https://devfeed.tech/tags/database.md>), [flow](<https://devfeed.tech/tags/flow.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [multithreading](<https://devfeed.tech/tags/multithreading.md>), [network](<https://devfeed.tech/tags/network.md>), [persistence](<https://devfeed.tech/tags/persistence.md>), [processing](<https://devfeed.tech/tags/processing.md>), [reactive-programming](<https://devfeed.tech/tags/reactive-programming.md>), [streams](<https://devfeed.tech/tags/streams.md>)

### AI overview

For high-frequency Flow data such as analytics events, collecting items over time intervals can reduce the cost of repeated database or network operations and keep that work from competing as often with higher-priority app tasks. The excerpt contrasts this time-based batching need with collection chunking by item count and introduces a custom Flow operator intended to emit chunks at fixed intervals. It does not include the implementation or explain how the operator handles timing and data retention.

### Source excerpt

Learn how to collect Kotlin Flow items in chunks or intervals without losing data. A practical guide to handling high-frequency data streams efficiently.

## Strategies for automatically refreshing data on Android using Kotlin Flow

DevFeed: [Strategies for automatically refreshing data on Android using Kotlin Flow](<https://devfeed.tech/articles/strategies-for-automatically-refreshing-data-on-android-using-kotlin-flow-25884.md>)

Original publisher: [Read original article](<https://bladecoder.medium.com/strategies-for-automatically-refreshing-data-on-android-using-kotlin-flow-cd23ba7cfbe0?source=rss-54910f05af37------2>)

Author: Christophe Beyls

Published: 2023-10-06T17:27:03Z

Content type: article

Language: en

Sources: [Christophe Beyls](<https://devfeed.tech/sources/stories-by-christophe-beyls-on-medium.md>)

Topics: [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [User Interfaces](<https://devfeed.tech/topics/user-interfaces.md>), [RxJava](<https://devfeed.tech/topics/rxjava.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [applications](<https://devfeed.tech/tags/applications.md>), [automatic](<https://devfeed.tech/tags/automatic.md>), [automatically](<https://devfeed.tech/tags/automatically.md>), [collect](<https://devfeed.tech/tags/collect.md>), [concurrently](<https://devfeed.tech/tags/concurrently.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [data](<https://devfeed.tech/tags/data.md>), [delay](<https://devfeed.tech/tags/delay.md>), [efficiently](<https://devfeed.tech/tags/efficiently.md>), [emissions](<https://devfeed.tech/tags/emissions.md>), [fixed](<https://devfeed.tech/tags/fixed.md>), [flow](<https://devfeed.tech/tags/flow.md>), [infinite](<https://devfeed.tech/tags/infinite.md>), [interface](<https://devfeed.tech/tags/interface.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-flow](<https://devfeed.tech/tags/kotlin-flow.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [load](<https://devfeed.tech/tags/load.md>), [sharedflow](<https://devfeed.tech/tags/sharedflow.md>), [strategies](<https://devfeed.tech/tags/strategies.md>)

### AI overview

For periodic Android refreshes, a basic ticker Flow emits immediately and then waits a fixed interval. Mapping loads with `map()` makes each interval begin after the previous load finishes; `mapLatest()` keeps the timer on schedule but cancels an unfinished load when the next tick arrives, so the interval should exceed typical load time. To avoid reloading still-fresh data when the UI resumes, `synchronizedTickerFlow()` remembers the next emission time and pauses its ticker when a shared `StateFlow` has no subscribers, preserving the cached value. Its timing needs a monotonic clock: Android's `SystemClock.elapsedRealtimeNanos()` includes deep sleep, unlike `System.nanoTime()`, which can make refresh late after the device sleeps. The article also shows sharing one cached time reference among periodic data sources so their results use a consistent reference point.

### Source excerpt

Making timers lifecycle-aware This is the third part of a series of articles discussing the usage of Kotlin Flow to efficiently load data in Android applications. It's a direct follow-up to part 2: "Smarter Shared Kotlin Flows", as it reuses the same concepts to cover another use case: automatic periodic refresh of the user interface. Simple periodic refresh When it's not possible to determine precisely when a data set displayed by the UI has changed, or when it changes too frequently, a common strategy is to reload the data periodically at a fixed interval while the screen is visible. One of the simplest ways to achieve this is to create a Flow from an infinite loop calling delay() between emissions: fun tickerFlow(period: Duration): Flow<Unit> = flow { while (true) { emit(Unit) // Tick delay(period) } } This is equivalent to the Observable.interval() operator in RxJava with a fixed emitted value (Unit) and an initial delay of 0. Then, transform this Flow using the map() or mapLatest() operator to perform the loading action on each "tick" of the timer and return the result: tickerFlow(REFRESH_INTERVAL) .map { repository.loadSomeData() } Note the subtle difference in behavior between the two operators: With map() the entire Flow will be executed in sequence within a single coroutine, meaning delay() will only start running after the loading operation completes. As a result, each loading operation will be delayed by the amount of time it took to perform the previous loading operation, plus the fixed interval. With mapLatest() the main coroutine will collect the upstream values of tickerFlow() while a child coroutine will be created to perform the loading operation concurrently and collect the result without suspending the main coroutine. This means that delay() will start running immediately after the previous tick and each loading operation will start precisely according to schedule. This also means that the interval must be longer than the typical loading time beca

## Context Receivers in Kotlin: An Example

DevFeed: [Context Receivers in Kotlin: An Example](<https://devfeed.tech/articles/context-receivers-in-kotlin-an-example-25676.md>)

Original publisher: [Read original article](<https://blog.sanskar10100.dev/context-receivers-in-kotlin-an-example>)

Author: Sanskar Agrawal

Published: 2023-02-26T16:21:57Z

Content type: article

Language: en

Sources: [Sanskar's Stuff](<https://devfeed.tech/sources/sanskar-s-stuff.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [explicit receiver](<https://devfeed.tech/topics/explicit-receiver.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [User Interfaces](<https://devfeed.tech/topics/user-interfaces.md>)

Tags: [1-6](<https://devfeed.tech/tags/1-6.md>), [android](<https://devfeed.tech/tags/android.md>), [backend](<https://devfeed.tech/tags/backend.md>), [collect](<https://devfeed.tech/tags/collect.md>), [example](<https://devfeed.tech/tags/example.md>), [extension-function](<https://devfeed.tech/tags/extension-function.md>), [feature](<https://devfeed.tech/tags/feature.md>), [fragment](<https://devfeed.tech/tags/fragment.md>), [function](<https://devfeed.tech/tags/function.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-flow](<https://devfeed.tech/tags/kotlin-flow.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [pattern](<https://devfeed.tech/tags/pattern.md>), [reactive](<https://devfeed.tech/tags/reactive.md>), [receiver](<https://devfeed.tech/tags/receiver.md>), [stateflow](<https://devfeed.tech/tags/stateflow.md>)

### AI overview

Kotlin extension functions have a single receiver, which limits a utility function that collects a StateFlow while handling a Fragment's lifecycle: the function must take the Fragment as an explicit argument. The author introduces context receivers as a way to make additional call-site context implicitly available in the function body. The excerpt ends before explaining their implementation or requirements.

### Source excerpt

Context Receivers are a new feature introduced in Kotlin 1.6.20. They're useful for receiving the context from the call-site when a function is called. To understand it and its utility, let's first take a look at a similar feature available in the la...

## My Coroutines Course just got a BIG update: Kotlin Flow for Android Development

DevFeed: [My Coroutines Course just got a BIG update: Kotlin Flow for Android Development](<https://devfeed.tech/articles/my-coroutines-course-just-got-a-big-update-kotlin-flow-for-android-development-25417.md>)

Original publisher: [Read original article](<https://www.lukaslechner.com/my-coroutines-course-just-got-a-big-update-kotlin-flow-for-android-development/>)

Author: Lukas Lechner

Published: 2022-11-21T14:57:43Z

Content type: release

Language: en

Sources: [Lukas Lechner](<https://devfeed.tech/sources/lukas-lechner.md>)

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

Tags: [allgemein](<https://devfeed.tech/tags/allgemein.md>), [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [course](<https://devfeed.tech/tags/course.md>), [flow](<https://devfeed.tech/tags/flow.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-flow](<https://devfeed.tech/tags/kotlin-flow.md>)

### AI overview

The Kotlin Coroutines for Android course has been expanded with modules on Kotlin Flow. The update adds six hours of video content, bringing the course to 15 hours total. The author describes it as a comprehensive course, but the excerpt provides no details about the modules' specific topics or instruction.

### Source excerpt

Hi Readers 👋 There hasn't been a lot of news from my side lately, but today I can announce something big! I spent the last months extending my already existing Course about Kotlin Coroutines for Android with modules about Kotlin Flow! The result is an additional 6 hours of video content about Kotlin Flow, making Read More The post My Coroutines Course just got a BIG update: Kotlin Flow for Android Development first appeared on Lukas Lechner.

## KStore

DevFeed: [KStore](<https://devfeed.tech/articles/kstore-25913.md>)

Original publisher: [Read original article](<https://medium.com/@xxfast/kstore-1be37dd7bc22?source=rss-43bae76e8f81------2>)

Author: Isuru Rajapakse

Published: 2022-10-02T16:01:17Z

Content type: article

Language: en

Sources: [Isuru Rajapakse](<https://devfeed.tech/sources/stories-by-isuru-rajapakse-on-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Tool](<https://devfeed.tech/topics/tool.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Software Testing](<https://devfeed.tech/topics/software-testing.md>), [coroutines-flow](<https://devfeed.tech/topics/coroutines-flow.md>), [CI/CD](<https://devfeed.tech/topics/cicd.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [delete](<https://devfeed.tech/tags/delete.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [documentation](<https://devfeed.tech/tags/documentation.md>), [flow](<https://devfeed.tech/tags/flow.md>), [github](<https://devfeed.tech/tags/github.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [integration](<https://devfeed.tech/tags/integration.md>), [interface](<https://devfeed.tech/tags/interface.md>), [jetbrains](<https://devfeed.tech/tags/jetbrains.md>), [json](<https://devfeed.tech/tags/json.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [kotlinx](<https://devfeed.tech/tags/kotlinx.md>), [library](<https://devfeed.tech/tags/library.md>), [multiplatform](<https://devfeed.tech/tags/multiplatform.md>), [mutex](<https://devfeed.tech/tags/mutex.md>), [release](<https://devfeed.tech/tags/release.md>), [repository](<https://devfeed.tech/tags/repository.md>)

### AI overview

KStore is a Kotlin Multiplatform library for saving and restoring objects on disk with kotlinx.coroutines, kotlinx.serialization and Okio. Its API creates a store for a file path and offers suspended get, set, delete and reset operations, plus a Flow of updates. The update operation applies a change under one mutex-lock transaction; the article contrasts this with calling get() and then set() separately. The author describes building and testing each platform through GitHub Actions, tracking unit-test coverage with Kotlinx Klover, and checking binary compatibility with JetBrains' validator. The library is described as available from Maven Central; the excerpt does not detail platform support beyond mentioning multiplatform builds.

### Source excerpt

A tiny Kotlin multiplatform library to save and restore objects to and from the disk So I put out a new library, my first Multiplatform library. KStore is a tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serializationand okio Why? A newer version of kotlinx.serialization was released and one thing caught my eye Integration with Okio's BufferedSource and BufferedSink Release 1.4.0-RC - Kotlin/kotlinx.serialization However, there was little to no documentation on how to use it. I scanned through the repository looking for tests but couldn't find any. I asked on slack Got nothing.. But I pulled it down and tried it out anyways. dependencies { implementation("org.jetbrains.kotlinx:kotlinx-serialization-json-okio:1.4.0") } Tried out the most obvious way and wrote up a test case Json.encodeToBufferedSink(value, FILE_SYSTEM.sink(path).buffer()) No luck. Asked around on slack once again Not a minute went by, and our lord and saviour himself descended from heaven to help me out After using use, it worked 🙌. His divinely presence inspired me to write out a bunch more test cases and put this out there in under ~48hrs GitHub - xxfast/KStore: A tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serialisation and okio API KStore is inspired by RxStore, and it provides a simple API. Most of these interface methods are suspended, and can only be invoked from a suspended context. SuspendedCreate a storeval store: KStore<Pet> = storeOf("path/to/file")Get valueval mylo: Pet? = store.get() Or observe for changes val pets: Flow<Pet?> = store.updatesSet valuestore.set(mylo)Update a valuestore.update { pet: Pet? -> pet?.copy(age = pet.age + 1) } Note: this maintains a single mutex lock transaction, unlike get() and a subsequent set() Delete/Reset valuestore.delete() You can also reset a value back to its default. store.reset()Sel

[Next page](<https://devfeed.tech/topics/coroutines-flow.md?cursor=WyIyMDIyLTEwLTAyVDE2OjAxOjE3KzAwOjAwIiwgIjdjMjNiZjYwLTI2MWUtNDA0ZS04N2Q2LWI0ZmZkMzdmMDQ5ZiJd>)