# Coroutine

Published articles for Coroutine.

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

## Hyperloop B: the coroutine engine behind Appwrite 2.0

DevFeed: [Hyperloop B: the coroutine engine behind Appwrite 2.0](<https://devfeed.tech/articles/hyperloop-b-the-coroutine-engine-behind-appwrite-2-0-16482.md>)

Original publisher: [Read original article](<https://appwrite.io/blog/post/hyperloop-b>)

Author: Luke B. Silver

Published: 2026-08-31T00:00:00Z

Content type: article

Language: en

Sources: [Appwrite Blog](<https://devfeed.tech/sources/appwrite-blog.md>)

Topics: [Appwrite](<https://devfeed.tech/topics/appwrite.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [PHP](<https://devfeed.tech/topics/php.md>), [Benchmark](<https://devfeed.tech/topics/benchmark.md>)

Tags: [architectures](<https://devfeed.tech/tags/architectures.md>), [backend](<https://devfeed.tech/tags/backend.md>), [benchmark](<https://devfeed.tech/tags/benchmark.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [memory](<https://devfeed.tech/tags/memory.md>), [php](<https://devfeed.tech/tags/php.md>), [platform](<https://devfeed.tech/tags/platform.md>), [process](<https://devfeed.tech/tags/process.md>), [redis](<https://devfeed.tech/tags/redis.md>)

### AI overview

The article explains Hyperloop B, a coroutine-based engine behind Appwrite 2.0. It describes how yielding during I/O lets one process serve many concurrent requests, reporting 7x higher requests per second and 6x lower memory use on an I/O-bound benchmark.

### Source excerpt

Hyperloop B is the Swoole coroutine engine behind Appwrite 2.0. Here is what it is, the concurrency problem it solves, and the 7x I/O throughput it buys.

## Native Async/Coroutine Reads in RocksDB

DevFeed: [Native Async/Coroutine Reads in RocksDB](<https://devfeed.tech/articles/native-async-coroutine-reads-in-rocksdb-22403.md>)

Original publisher: [Read original article](<http://rocksdb.org/blog/2026/08/24/native-coroutine-reads.html>)

Author: Josh Kang

Published: 2026-08-24T00:00:00Z

Content type: release

Language: en

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

Topics: [rocksdb](<https://devfeed.tech/topics/rocksdb.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [C++](<https://devfeed.tech/topics/c-plus-plus.md>), [IO](<https://devfeed.tech/topics/io.md>), [API](<https://devfeed.tech/topics/api.md>)

Tags: [async](<https://devfeed.tech/tags/async.md>), [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [blog](<https://devfeed.tech/tags/blog.md>), [c-plus-plus](<https://devfeed.tech/tags/c-plus-plus.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [io](<https://devfeed.tech/tags/io.md>), [native](<https://devfeed.tech/tags/native.md>), [rocksdb](<https://devfeed.tech/tags/rocksdb.md>), [thread](<https://devfeed.tech/tags/thread.md>)

### AI overview

RocksDB introduces experimental asynchronous Get and MultiGet APIs backed by native C++ coroutines. The APIs can suspend storage-bound reads, allowing a small executor to run other ready tasks and maintain more storage queue depth without one blocked application thread per read. The feature targets throughput for I/O-bound point lookups rather than reducing individual device-read latency.

### Source excerpt

A point lookup that misses RocksDB's block cache can spend most of its time waiting for storage. The traditional way to keep more reads in flight is to add threads. That works, but each outstanding read parks a thread, carries a stack, and adds context-switching overhead. RocksDB now has experimental asynchronous Get and MultiGet APIs backed by native C++ coroutines. When a read reaches storage, RocksDB can suspend the request, let its read-executor worker run another ready task, and resume the request when the filesystem reports completion. A small executor can therefore maintain more storage queue depth without requiring one blocked application thread per read. These APIs are available in RocksDB 11.10.0. This is primarily a throughput feature for I/O-bound point lookups. It does not make an individual device read faster. Its benefit comes from keeping the device busy and using CPU threads for runnable work. The API surface RocksDB exposes the new read path through two public interfaces: DB::GetAsync and DB::MultiGetAsync return immediately on the native path and report completion through AsyncCallback::OnComplete. CoroDB::CoGet and CoroDB::CoMultiGet return lazy folly::coro::Task objects. CoGet produces a Status; CoMultiGet fills the same per-key values and statuses as synchronous MultiGet. The callback APIs suit applications that do not expose Folly tasks at their boundaries. The CoroDB APIs let coroutine-based callers await RocksDB directly, avoiding an application-side callback-to-Baton adapter and its extra completion handoff. Native execution requires RocksDB to be built with Folly and USE_COROUTINES=1. Neither interface requires ReadOptions::async_io. That flag continues to control the older internal async-I/O optimizations for synchronous MultiGet and iterators. The task APIs are lazy: no read begins until a task is awaited or started. Both interfaces take pointer and reference parameters, so keep the DB, column-family handles, ReadOptions, keys and their

## Coroutine Essentials

DevFeed: [Coroutine Essentials](<https://devfeed.tech/articles/coroutine-essentials-25051.md>)

Original publisher: [Read original article](<https://typealias.com/start/kotlin-coroutines/>)

Author: author@typealias.com (Dave Leeds)

Published: 2026-08-21T00:00:00Z

Content type: tutorial

Language: en

Sources: [Dave Leeds on Kotlin - typealias.com](<https://devfeed.tech/sources/dave-leeds-on-kotlin-typealias-com.md>)

Topics: [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [coding](<https://devfeed.tech/topics/coding.md>), [Software](<https://devfeed.tech/topics/software.md>)

Tags: [async](<https://devfeed.tech/tags/async.md>), [cancellation](<https://devfeed.tech/tags/cancellation.md>), [coding](<https://devfeed.tech/tags/coding.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [deferred](<https://devfeed.tech/tags/deferred.md>), [dispatcher](<https://devfeed.tech/tags/dispatcher.md>), [exception-handling](<https://devfeed.tech/tags/exception-handling.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [job](<https://devfeed.tech/tags/job.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [launch](<https://devfeed.tech/tags/launch.md>), [learn-to-program](<https://devfeed.tech/tags/learn-to-program.md>), [parallelism](<https://devfeed.tech/tags/parallelism.md>), [programming](<https://devfeed.tech/tags/programming.md>), [runblocking](<https://devfeed.tech/tags/runblocking.md>), [software](<https://devfeed.tech/tags/software.md>), [structured-concurrency](<https://devfeed.tech/tags/structured-concurrency.md>), [suspend-function](<https://devfeed.tech/tags/suspend-function.md>), [withcontext](<https://devfeed.tech/tags/withcontext.md>), [yield](<https://devfeed.tech/tags/yield.md>)

### AI overview

This tutorial introduces essential Kotlin coroutine concepts for performing multiple tasks concurrently, such as making network calls while updating a screen. It aims to provide a foundation for day-to-day coding and more advanced coroutine concepts.

### Source excerpt

When you're on hold during a phone call, you might also check your email. While brewing coffee, you might also cook breakfast. And while driving a car, you might listen to a podcast. In the same way, sometimes it's helpful for the software that we write to do more than one thing at a time. For example, it could make two or three network calls at one time--all while updating the screen to show the progress of each call.

## How to Prevent Race Conditions in Coroutines

DevFeed: [How to Prevent Race Conditions in Coroutines](<https://devfeed.tech/articles/how-to-prevent-race-conditions-in-coroutines-25006.md>)

Original publisher: [Read original article](<https://typealias.com/articles/prevent-race-conditions-in-coroutines/>)

Author: author@typealias.com (Dave Leeds)

Published: 2025-11-24T00:00:00Z

Content type: tutorial

Language: en

Sources: [Dave Leeds on Kotlin - typealias.com](<https://devfeed.tech/sources/dave-leeds-on-kotlin-typealias-com.md>)

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

Tags: [actor](<https://devfeed.tech/tags/actor.md>), [atomicint](<https://devfeed.tech/tags/atomicint.md>), [atomics](<https://devfeed.tech/tags/atomics.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.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>), [limitedparallelism](<https://devfeed.tech/tags/limitedparallelism.md>), [mutex](<https://devfeed.tech/tags/mutex.md>), [programming](<https://devfeed.tech/tags/programming.md>), [race-condition](<https://devfeed.tech/tags/race-condition.md>), [shared-mutable-state](<https://devfeed.tech/tags/shared-mutable-state.md>), [state](<https://devfeed.tech/tags/state.md>), [stateflow](<https://devfeed.tech/tags/stateflow.md>), [structured-concurrency](<https://devfeed.tech/tags/structured-concurrency.md>)

### AI overview

This tutorial explains that Kotlin coroutines and structured concurrency do not automatically protect shared mutable state from race conditions. It introduces the issue using an example that creates 100,000 random bakery orders.

### Source excerpt

Thanks to structured concurrency, there are a lot of concerns that we don't have to handle manually when working with Kotlin coroutines. For example, parent coroutines automatically wait for their children to complete before completing themselves. And when a parent coroutine is cancelled, its children are automatically cancelled, too. But when it comes to shared mutable state - mutable data that multiple coroutines could update at the same time - there's nothing magical in the design of coroutines to ensure that the state is updated properly.

## Understanding Dispatchers: Main and Main.immediate

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

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

Author: Shreyas Patil

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

Content type: tutorial

Language: en

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

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

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

### AI overview

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

### Source excerpt

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

## Dispatchers.Unconfined and why you actually want EmptyCoroutineContext

DevFeed: [Dispatchers.Unconfined and why you actually want EmptyCoroutineContext](<https://devfeed.tech/articles/dispatchers-unconfined-and-why-you-actually-want-emptycoroutinecontext-29008.md>)

Original publisher: [Read original article](<https://code.cash.app/dispatchers-unconfined>)

Author: Colin White

Published: 2025-01-15T00:00:00Z

Content type: tutorial

Language: en

Sources: [Cash App Code Blog](<https://devfeed.tech/sources/cash-app-code-blog.md>)

Topics: [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>)

Tags: [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [dispatcher](<https://devfeed.tech/tags/dispatcher.md>), [io](<https://devfeed.tech/tags/io.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [test](<https://devfeed.tech/tags/test.md>), [testing](<https://devfeed.tech/tags/testing.md>)

### AI overview

The article explains why Dispatchers.Unconfined can introduce subtle threading bugs and crashes by avoiding thread dispatching. It recommends using EmptyCoroutineContext when injecting dispatchers, allowing synchronous tests while preserving correct dispatching when coroutine contexts change.

### Source excerpt

Use EmptyCoroutineContext instead of Dispatchers.Unconfined.

## Coroutines and Dispatchers

DevFeed: [Coroutines and Dispatchers](<https://devfeed.tech/articles/coroutines-and-dispatchers-22871.md>)

Original publisher: [Read original article](<https://medium.com/mindorks/coroutines-and-dispatchers-b559094b828e?source=rss----f1a763fc7443---4>)

Author: Bigyan Thapa

Published: 2024-10-16T06:48:00Z

Content type: tutorial

Language: en

Sources: [Mindorks - Medium](<https://devfeed.tech/sources/mindorks-medium.md>)

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

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-development](<https://devfeed.tech/tags/android-development.md>), [androiddev](<https://devfeed.tech/tags/androiddev.md>), [best-practices](<https://devfeed.tech/tags/best-practices.md>), [code-quality](<https://devfeed.tech/tags/code-quality.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [dispatcher](<https://devfeed.tech/tags/dispatcher.md>), [extension](<https://devfeed.tech/tags/extension.md>), [extension-function](<https://devfeed.tech/tags/extension-function.md>), [io](<https://devfeed.tech/tags/io.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [main-thread](<https://devfeed.tech/tags/main-thread.md>)

### AI overview

This tutorial explains how Android ViewModel coroutines use viewModelScope and how to select Dispatchers.IO, Dispatchers.Default, or Dispatchers.Main for I/O, CPU-intensive, and UI work. It also presents ViewModel extension functions and an overloaded function to standardize coroutine launching.

### Source excerpt

In Android development, coroutines are commonly launched from ViewModel classes using viewModelScope. The typical usage looks like this: viewModelScope.launch { // ... implementation } In Android development, coroutines are commonly launched from ViewModel classes using viewModelScope. The typical usage looks like this: viewModelScope.launch { // ... implementation } By default, if a dispatcher is not specified, any coroutine launched in viewModelScope will run on the main thread. However, in most use cases, we launch these coroutines to perform background tasks, such as -- making API calls, or database operations. To ensure these tasks run in the background thread, it is essential to specify an appropriate dispatcher: I/O tasks should use Dispatchers.IO CPU-intensive tasks should use Dispatchers.Default UI updates should use Dispatchers.Main For example, to run an I/O task, we can specify the dispatcher like this: viewModelScope.launch(Dispatchers.IO) { // ...implementation }Optimizing Coroutine Launching To streamline coroutine launching, we can create extension functions on ViewModel that automatically use the specified dispatcher by default. Step 1: Create Extension Functions We can define extension functions for different dispatchers: kotlin fun ViewModel.launchIO(block: suspend CoroutineScope.() -> Unit) { viewModelScope.launch(Dispatchers.IO, block = block) } fun ViewModel.launchDefault(block: suspend CoroutineScope.() -> Unit) { viewModelScope.launch(Dispatchers.Default, block = block) } fun ViewModel.launchMain(block: suspend CoroutineScope.() -> Unit) { viewModelScope.launch(Dispatchers.Main, block = block) }Step 2: Use the Extension Functions You can now use these extension functions in your ViewModel as follows: class MyViewModel : ViewModel() { fun fetchData() { launchIO { // ... implementation } } } Benefits Consistency: These extension functions maintain consistent coroutine usage for specific tasks. Readability: The function names clearly indicate their p

## Coroutine Testing - Controlling time

DevFeed: [Coroutine Testing - Controlling time](<https://devfeed.tech/articles/coroutine-testing-controlling-time-25238.md>)

Original publisher: [Read original article](<https://kau.sh/blog/coroutine-testing-time/>)

Author: Kaushik Gopal

Published: 2024-09-04T07:00:00Z

Content type: tutorial

Language: en

Sources: [Kaushik Gopal's Site](<https://devfeed.tech/sources/kaushik-gopal-s-site.md>)

Topics: [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutine-testing](<https://devfeed.tech/tags/coroutine-testing.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [test](<https://devfeed.tech/tags/test.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tests](<https://devfeed.tech/tags/tests.md>), [time](<https://devfeed.tech/tags/time.md>)

### AI overview

This tutorial explains virtual time in coroutine tests, focusing on the runCurrent, advanceTimeBy, and advanceUntilIdle APIs. It distinguishes scheduling from execution and demonstrates how StandardTestDispatcher and TestCoroutineScheduler affect test results.

### Source excerpt

series This is part of a series of posts on Coroutine Testing: Picking the right Dispatcher Never ending tests & backgroundscope Controlling time <- Helpful @Junit TestRule extension (coming soon) Full USF example for Android (coming soon) My journey with coroutine testing started with this "simple" requirement -- to control virtual time in concurrent logic. From my previous post: ... If you don't use a StandardTestDispatcher explicitly, then operators like runCurrent, advanceTimeBy etc. have no meaning. I have a confession to make. I was coy saying "have no meaning". I didn't say "won't work" because in reality those apis will "work" just not in the way you'd expect. Let's dive deeper. The 3 apis # There are 3 important apis in coroutine tests to play with time: runCurrent - execute tasks scheduled at the current moment of virtual time advanceTimeBy - advance virtual time by a number of milliseconds and then execute tasks scheduled in the meantime. advanceUntilIdle - similar to advanceTimeBy but instead of advancing by a specific number of milliseconds, it keeps advancing until no more scheduled tasks are found. In the context of coroutine testing, when you think of "time", it refers simply to the order that the TestCoroutineScheduler decides to execute your scheduled coroutines. That's why the definitions above stress on words "execute" vs "scheduled". In reality, these apis belong to the class TestCoroutineScheduler (not StandardTestDispatcher as the coy comment might have indicated). Let's attempt to understand this all, with some code. StandardTestDispatcher & the 3 apis # This animation should illustrate how the different apis are designed to work.1 Your browser doesn't support HTML5 video. Download the video instead. StandardTestDispatcher is good about respecting the 3 apis. A basic test demonstrating the use of runCurrent that shouldn't be surprising: @Test fun test() = runTest(StandardTestDispatcher()) { var result = "X" launch { result = "A" delay(1.seconds)

## Coroutine Testing - Never ending tests & backgroundScope

DevFeed: [Coroutine Testing - Never ending tests & backgroundScope](<https://devfeed.tech/articles/coroutine-testing-never-ending-tests-backgroundscope-25236.md>)

Original publisher: [Read original article](<https://kau.sh/blog/coroutine-testing-backgroundscope/>)

Author: Kaushik Gopal

Published: 2024-08-30T07:00:45Z

Content type: tutorial

Language: en

Sources: [Kaushik Gopal's Site](<https://devfeed.tech/sources/kaushik-gopal-s-site.md>)

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

Tags: [android](<https://devfeed.tech/tags/android.md>), [channel](<https://devfeed.tech/tags/channel.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutine-testing](<https://devfeed.tech/tags/coroutine-testing.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [flow](<https://devfeed.tech/tags/flow.md>), [job](<https://devfeed.tech/tags/job.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [stateflow](<https://devfeed.tech/tags/stateflow.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tests](<https://devfeed.tech/tags/tests.md>), [unit-testing](<https://devfeed.tech/tags/unit-testing.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>)

### AI overview

This tutorial explains why coroutine tests can time out when they collect from non-terminating Channels, SharedFlow, StateFlow, or ViewModel jobs. It presents manual Job cancellation and backgroundScope, which cancels child coroutines when the test body completes.

### Source excerpt

series This is part of a series of posts on Coroutine Testing: Picking the right Dispatcher Never ending tests & backgroundscope <- Controlling time Helpful @Junit TestRule extension (coming soon) Full USF example for Android (coming soon) If you've spent some time testing Coroutines this exception should look familiar: After waiting for 1m, the test coroutine is not completing, there were active child jobs This tends to happen when you have a coroutine job in your test, that fails to complete on its own. Let's take a simple example. src on github We use a Channel here which is the proverbial event bus for Coroutines. source: kotlinlang.org Channels don't terminate on their own. So when you run a simple test checking the emission, while the items might get collected correctly per the assert statement in the test, the test itself fails like so: test on github The test here is waiting for that coroutine job to complete, which in turn requires the Channel to, but that never happens and the test times out. Where else would I run into this problem? # Channels aren't the only case you'll run into this problem. For example if you use a "hot" Flow like SharedFlow or StateFlow, they don't terminate on their own, so the onus is on you to complete or cancel their Job in tests. Android developers can frequently run into this problem too if you use ViewModels and have an internal StateFlow providing your "view level data" (what i personally like to call "view state"). You typically use the viewModelScope to launch internal coroutine jobs in a ViewModel. The OS then calls the lifecycle method onClear when the Activity or Fragment no longer needs the ViewModel where all jobs started in the viewModelScope are canceled. But when unit testing these ViewModels, you don't have access to the viewModelScope and shouldn't need it anyway. Solving this problem # There's two ways to solve this problem: 1. Manually cancel the Job ## If you have access to the Job that spawns the never-ending co

## Coroutine Testing

DevFeed: [Coroutine Testing](<https://devfeed.tech/articles/coroutine-testing-25239.md>)

Original publisher: [Read original article](<https://kau.sh/blog/coroutine-testing/>)

Author: Kaushik Gopal

Published: 2024-08-25T07:00:45Z

Content type: tutorial

Language: en

Sources: [Kaushik Gopal's Site](<https://devfeed.tech/sources/kaushik-gopal-s-site.md>)

Topics: [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [LineageOS](<https://devfeed.tech/topics/lineageos.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutine-testing](<https://devfeed.tech/tags/coroutine-testing.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [dispatcher](<https://devfeed.tech/tags/dispatcher.md>), [flaky](<https://devfeed.tech/tags/flaky.md>), [junit](<https://devfeed.tech/tags/junit.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [migration-guide](<https://devfeed.tech/tags/migration-guide.md>), [testing](<https://devfeed.tech/tags/testing.md>), [time](<https://devfeed.tech/tags/time.md>), [tutorials](<https://devfeed.tech/tags/tutorials.md>)

### AI overview

A tutorial series on testing Kotlin coroutines in Android applications. It discusses changes to Kotlin testing APIs, unreliable virtual-time advancement, flaky tests, dispatchers, background scopes, and controlling time.

### Source excerpt

When the #androiddevs transitioned from Rx to coroutines the topic of testing didn't get as much attention in this new world of concurrency. It didn't help that there was a seismic change in Kotlin's testing apis with 1.6.0. A whole bunch of online resources and tutorials are now defunct courtesy this change.1 My journey in the matter started because I simply couldn't understand why test apis like advanceTimeBy wouldn't work reliably for me. The name made sense... but my time wasn't being advanced in any meaningful way. Then there's the issue of flaky tests. Here's an example: flaky test code on github Run each test individually and it will pass; run them together as one test suite and test2 alone will fail. test1 passes but it takes a full 3s to run the test. If I have 300 of these in my app, are my tests going to take 15 minutes to run? I needed to understand many core concepts in order to confidently explain all the above phenomena. I'd like to share my learnings from going down the rabbit hole, in this series of posts: series This is part of a series of posts on Coroutine Testing: <- Picking the right Dispatcher Never ending tests & backgroundscope Controlling time Helpful @Junit TestRule extension (coming soon) Full USF example for Android (coming soon) If you're looking for the most current and useful resources on coroutine testing today: Untangling Coroutine Testing - Marton Braun jetbrains official docs developer.android.com docs 1.6.0 Coroutines test migration guide ↩︎

## How many threads does your network client use?

DevFeed: [How many threads does your network client use?](<https://devfeed.tech/articles/how-many-threads-does-your-network-client-use-39355.md>)

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

Published: 2024-05-13T00:00:00Z

Content type: tutorial

Language: en

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

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [kotlin-coroutines](<https://devfeed.tech/topics/kotlin-coroutines.md>), [Ktor](<https://devfeed.tech/topics/ktor.md>), [Spring Boot](<https://devfeed.tech/topics/spring-boot.md>), [client](<https://devfeed.tech/topics/client.md>), [Network](<https://devfeed.tech/topics/network.md>)

Tags: [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [ktor](<https://devfeed.tech/tags/ktor.md>), [network](<https://devfeed.tech/tags/network.md>), [spring-boot](<https://devfeed.tech/tags/spring-boot.md>), [threads](<https://devfeed.tech/tags/threads.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

### AI overview

This article examines how network clients can consume more threads than expected in Kotlin applications. It explains the thread and memory costs of blocking network requests, contrasts them with suspended Kotlin coroutines, and discusses checking client behavior in Ktor and Spring Boot applications.

### Source excerpt

Many popular network clients consume way more threads than you might expect. Let's overview the problem and find a solution.

## 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: tutorial

Language: en

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

Topics: [kotlin-flow](<https://devfeed.tech/topics/kotlin-flow.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Android](<https://devfeed.tech/topics/android.md>), [RxJava](<https://devfeed.tech/topics/rxjava.md>), [ui](<https://devfeed.tech/topics/ui.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>), [api](<https://devfeed.tech/tags/api.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [flow](<https://devfeed.tech/tags/flow.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-flow](<https://devfeed.tech/tags/kotlin-flow.md>), [rxjava](<https://devfeed.tech/tags/rxjava.md>), [sharedflow](<https://devfeed.tech/tags/sharedflow.md>), [ui](<https://devfeed.tech/tags/ui.md>)

### AI overview

This tutorial explains how to periodically refresh data in Android user interfaces with Kotlin Flow. It compares sequential map() processing with concurrent, cancellation-aware mapLatest() processing and discusses lifecycle-aware refreshing and caching considerations.

### 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

## Implementing Multiplatform Kotlin Mobile

DevFeed: [Implementing Multiplatform Kotlin Mobile](<https://devfeed.tech/articles/implementing-multiplatform-kotlin-mobile-39207.md>)

Original publisher: [Read original article](<https://kt.academy/article/ak-kmp-kmm>)

Published: 2023-09-25T00:15:00Z

Content type: tutorial

Language: en

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

Topics: [Kotlin Multiplatform](<https://devfeed.tech/topics/kotlin-multiplatform.md>), [multiplatform](<https://devfeed.tech/topics/multiplatform.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [Android](<https://devfeed.tech/topics/android.md>), [iOS](<https://devfeed.tech/topics/ios.md>), [Development](<https://devfeed.tech/topics/development.md>), [business logic](<https://devfeed.tech/topics/business-logic.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [business-logic](<https://devfeed.tech/tags/business-logic.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [ios](<https://devfeed.tech/tags/ios.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [logic](<https://devfeed.tech/tags/logic.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [multiplatform](<https://devfeed.tech/tags/multiplatform.md>), [text-to-speech](<https://devfeed.tech/tags/text-to-speech.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

### AI overview

This tutorial explains how Kotlin Multiplatform Mobile can share business logic between Android and iOS applications. It covers shared modules, generated platform libraries, ViewModel expect/actual classes, coroutine scopes, and interfaces for platform-specific dependencies such as text-to-speech.

### Source excerpt

How in Kotlin we can implement Android and iOS projects with shared logic.

## Using annotations to improve iOS APIs on Kotlin Multiplatform

DevFeed: [Using annotations to improve iOS APIs on Kotlin Multiplatform](<https://devfeed.tech/articles/using-annotations-to-improve-ios-apis-on-kotlin-multiplatform-25572.md>)

Original publisher: [Read original article](<https://www.marcogomiero.com/posts/2023/objc-annotiations-better-kmp-api/>)

Author: Marco Gomiero

Published: 2023-09-19T00:00:00Z

Content type: article

Language: en

Sources: [Posts on Marco Gomiero](<https://devfeed.tech/sources/posts-on-marco-gomiero.md>)

Topics: [Kotlin Multiplatform](<https://devfeed.tech/topics/kotlin-multiplatform.md>), [interoperability](<https://devfeed.tech/topics/interoperability.md>), [iOS](<https://devfeed.tech/topics/ios.md>), [Objective-C](<https://devfeed.tech/topics/objective-c.md>), [Swift](<https://devfeed.tech/topics/swift.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [multiplatform](<https://devfeed.tech/topics/multiplatform.md>)

Tags: [architecture](<https://devfeed.tech/tags/architecture.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [interoperability](<https://devfeed.tech/tags/interoperability.md>), [ios](<https://devfeed.tech/tags/ios.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-multiplatform](<https://devfeed.tech/tags/kotlin-multiplatform.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [objective-c](<https://devfeed.tech/tags/objective-c.md>), [swift](<https://devfeed.tech/tags/swift.md>)

### AI overview

This article explains how Kotlin 1.8 annotations can improve iOS APIs in a Kotlin Multiplatform project. It describes using @HiddenFromObjC and @ObjCName to expose iOS-specific implementations with clearer names while keeping shared business logic and reducing misleading duplicate class names.

### Source excerpt

Kotlin 1.8 has introduced new annotations to improve the interoperability of Kotlin with Objective-C and Swift: @ObjCName: allows to customize the name that will be used in Swift or Objective-C @HiddenFromObjC: allows hiding a Kotlin declaration from Objective-C (and Swift). @ShouldRefineInSwift: it marks a Kotlin declaration as swift_private in the Objective-C API, allowing to replace it with a wrapper written in Swift. You can see the release announcement for more details about the interoperability improvements introduced with Kotlin 1.8.

## Concurrent Programming in Kotlin: Ensuring Thread Safety with Mutex

DevFeed: [Concurrent Programming in Kotlin: Ensuring Thread Safety with Mutex](<https://devfeed.tech/articles/concurrent-programming-in-kotlin-ensuring-thread-safety-with-mutex-23873.md>)

Original publisher: [Read original article](<https://engineering.premise.com/concurrent-programming-in-kotlin-ensuring-thread-safety-with-mutex-5d9c6b80644b?source=rss----c5fada0a103d---4>)

Author: Kwabena Bio Berko

Published: 2023-07-18T03:33:24Z

Content type: tutorial

Language: en

Sources: [Engineering at Premise - Medium](<https://devfeed.tech/sources/engineering-at-premise-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Database](<https://devfeed.tech/topics/database.md>), [Software Engineering](<https://devfeed.tech/topics/software-engineering.md>)

Tags: [atomic](<https://devfeed.tech/tags/atomic.md>), [code](<https://devfeed.tech/tags/code.md>), [component](<https://devfeed.tech/tags/component.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [concurrent](<https://devfeed.tech/tags/concurrent.md>), [concurrent-programming](<https://devfeed.tech/tags/concurrent-programming.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [data](<https://devfeed.tech/tags/data.md>), [database](<https://devfeed.tech/tags/database.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [function](<https://devfeed.tech/tags/function.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [io](<https://devfeed.tech/tags/io.md>), [issue](<https://devfeed.tech/tags/issue.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [let](<https://devfeed.tech/tags/let.md>), [mobile-app-development](<https://devfeed.tech/tags/mobile-app-development.md>), [mutex](<https://devfeed.tech/tags/mutex.md>), [safety](<https://devfeed.tech/tags/safety.md>), [suspend](<https://devfeed.tech/tags/suspend.md>), [thread](<https://devfeed.tech/tags/thread.md>)

### AI overview

This Kotlin tutorial explains how Mutex provides mutual exclusion when multiple threads or coroutines call a refresh function. It shows how locking can prevent duplicate network and database operations, avoid race conditions, and preserve atomicity, while withLock can suspend callers until the current lock is released.

### Source excerpt

By Kwabena Bio Berko, Android Engineer Photo by Chris Ried on Unsplash I have recently been experimenting with mutual exclusion(Mutex), a concept in software engineering to solve race conditions when accessing shared resources. Let's assume we have a component with a refresh function that can be accessed from multiple threads or coroutines: https://medium.com/media/e19aa2a9d57bc105b841d28061a199b8/href In the implementation of this component, the function retrieves data from a remote resource and inserts it into the local database. However, these operations need to be atomic. Now, imagine if 10 threads call this function simultaneously, or even a few milliseconds apart. What happens? If you guessed that we make 10 network calls and 10 database IO operations to save the items, then you would be right, as confirmed by the below test: https://medium.com/media/9b279658dbf87021068ee21a913dc80e/hrefhttps://medium.com/media/81cdc164ad807fd45df77389c00bd4cc/href But that's not what we want. It's definitely not resource-friendly. To address this issue, we can use a Mutex. As the name suggests, a Mutex provides mutual exclusion for a specific portion of your code, imposing restrictions on the access to that portion in situations where multiple threads or coroutines may attempt to access it concurrently. In essence, Mutex allows only one thread or coroutine to work within the confines of that portion of the code at any given time. By introducing a Mutex in our refresh function, we can ensure that only one thread is executing the critical sections of the code, preventing race conditions and ensuring atomicity of the operations. https://medium.com/media/9d88a802b4c73f14ceb4d5527158af5d/href In the example above, whenever the refresh function is called, we check to see if the Mutex is already locked or been used. If not, we lock it and then perform our network call and save the results in our local database. This means that whenever another thread or coroutine calls this refresh

## Eliminating coroutine races

DevFeed: [Eliminating coroutine races](<https://devfeed.tech/articles/eliminating-coroutine-races-39297.md>)

Original publisher: [Read original article](<https://kt.academy/article/eliminating-coroutine-races>)

Published: 2023-06-26T00:00:00Z

Content type: tutorial

Language: en

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

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

Tags: [await](<https://devfeed.tech/tags/await.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.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

This tutorial explains how coroutine races occur when coroutines start in an unpredictable order and presents ways to coordinate them. It covers awaiting a completed coroutine, handling listener and event races in Android MVI scenarios, and using replay or completion signals for flows.

### Source excerpt

How to make one coroutine await for another coroutine or flow subscription.

## OkLayoutInflater: Improving Android XML Layout Inflation with Parallel Coroutines

DevFeed: [OkLayoutInflater: Improving Android XML Layout Inflation with Parallel Coroutines](<https://devfeed.tech/articles/oklayoutinflater-37405.md>)

Original publisher: [Read original article](<https://medium.com/okcredit/oklayoutinflater-3c5cd93c6ebc?source=rss----40ea5327aac7---4>)

Author: Anjal Saneen

Published: 2022-10-26T01:27:02Z

Content type: tutorial

Language: en

Sources: [OkCredit - Medium](<https://devfeed.tech/sources/okcredit-medium.md>)

Topics: [Android](<https://devfeed.tech/topics/android.md>), [XML](<https://devfeed.tech/topics/xml.md>), [Code](<https://devfeed.tech/topics/code.md>), [Parsing](<https://devfeed.tech/topics/parsing.md>), [implementation](<https://devfeed.tech/topics/implementation.md>), [IO](<https://devfeed.tech/topics/io.md>), [callback](<https://devfeed.tech/topics/callback.md>), [interface](<https://devfeed.tech/topics/interface.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>), [anr](<https://devfeed.tech/tags/anr.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [file](<https://devfeed.tech/tags/file.md>), [io](<https://devfeed.tech/tags/io.md>), [main-thread](<https://devfeed.tech/tags/main-thread.md>), [memory](<https://devfeed.tech/tags/memory.md>), [mobile-app-development](<https://devfeed.tech/tags/mobile-app-development.md>), [parallelism](<https://devfeed.tech/tags/parallelism.md>), [parsing](<https://devfeed.tech/tags/parsing.md>), [performance](<https://devfeed.tech/tags/performance.md>)

### AI overview

This tutorial explains how OkLayoutInflater addresses limitations in AndroidX AsyncLayoutInflater. It describes the existing implementation's sequential background inflation and presents a coroutine-based approach intended to use parallelism based on CPU cores, helping recycler view items load and scroll faster.

### Source excerpt

The loading of large XML layouts is one of the major performance bottlenecks in android. Loading XML layout into memory through IO operations and parsing views through reflection can be expensive. This is especially true when the XML file is too large or when initializing the layout view takes a while. We know that when the main thread performs some time-consuming operations, it may cause the page to freeze, and even more, serious ANR may occur. Androidx AsyncLayoutInflater helps to load those layouts asynchronously. However, we found that it has some limitations. The goal of this blog post is to explain how OkLayoutInflater addresses these limitations. Source code analysis of AndroidX AsyncLayoutInflater https://android.googlesource.com/platform/frameworks/support/+/89f7eba/v4/java/android/support/v4/view/AsyncLayoutInflater.java Source code is short and easy to understand with only a few lines of code. In the inflate method, it creates an InflateRequest object and stores variables such as resid, parent, callback, etc. Then it calls enqueue to add the request to the InflateThread queue. The main purpose of InflateThread is to add requests to the blocking queue and perform BasicInflater.inflate operations in order. Regardless of inflating success or failure, the request message will be sent to the main thread for processing. The BasicInflater Inherited from LayoutInflater. In OnCreateView these prefixes are loaded on the layout. At last, mHandlerCallback implements handleMessage which executes the operation on main thread, and there is a fallback mechanism, that is when the child thread inflates fails. it will continue to inflate on the main thread, and finally, gives a callback to the main thread through the OnInflateFinishedListener interface. The limitations of AsyncLayoutInflater and how we improve it Single thread to do all the inflate work AsyncLayoutInflater has this major limitation. This was the main reason for creating a custom implementation. One of our r

## Using Coroutines and Flows with Firebase on an Android app

DevFeed: [Using Coroutines and Flows with Firebase on an Android app](<https://devfeed.tech/articles/using-coroutines-and-flows-with-firebase-on-an-android-app-16483.md>)

Original publisher: [Read original article](<https://firebase.blog/posts/2022/10/using-coroutines-flows-with-firebase-on-android>)

Author: Marina Coelho

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

Content type: tutorial

Language: en

Sources: [Firebase Blog](<https://devfeed.tech/sources/firebase-blog.md>)

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

Tags: [android](<https://devfeed.tech/tags/android.md>), [compose](<https://devfeed.tech/tags/compose.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [firebase](<https://devfeed.tech/tags/firebase.md>), [flow](<https://devfeed.tech/tags/flow.md>), [how-to](<https://devfeed.tech/tags/how-to.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>)

### AI overview

A tutorial on replacing callback-based Firebase service calls with Kotlin Coroutines and Kotlin Flow in an Android application built with Jetpack Compose. It covers Firebase Authentication and Cloud Firestore examples.

### Source excerpt

Learn how to use Kotlin Coroutines and Kotlin Flows with Firebase on an Android app built with Jetpack Compose.

## Combining StateFlows and transforming it into a StateFlow

DevFeed: [Combining StateFlows and transforming it into a StateFlow](<https://devfeed.tech/articles/combining-stateflows-and-transforming-it-into-a-stateflow-25707.md>)

Original publisher: [Read original article](<https://blog.shreyaspatil.dev/combining-stateflows-and-transforming-it-into-a-stateflow/>)

Author: Shreyas Patil

Published: 2022-06-24T12:30:00Z

Content type: tutorial

Language: en

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

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [multithreading](<https://devfeed.tech/tags/multithreading.md>), [state-management](<https://devfeed.tech/tags/state-management.md>), [stateflow](<https://devfeed.tech/tags/stateflow.md>)

### AI overview

A Kotlin tutorial about combining multiple StateFlows into a derived StateFlow. It explains limitations of existing Flow-combining approaches, including conversion requirements such as a scope and separately calculated initial state.

### Source excerpt

Master the art of combining multiple StateFlows into a single transformed StateFlow. Explore utilities and best practices for managing complex states in Kotlin.

## Test Coroutine Scheduler

DevFeed: [Test Coroutine Scheduler](<https://devfeed.tech/articles/test-coroutine-scheduler-22665.md>)

Original publisher: [Read original article](<https://www.valueof.io/blog/test-coroutine-scheduler-dispatcher-main-rule>)

Author: James Shvarts

Published: 2022-06-24T00:55:12Z

Content type: tutorial

Language: en

Sources: [Android Blog - Mobile Dev Notes](<https://devfeed.tech/sources/android-blog-mobile-dev-notes.md>)

Topics: [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Exception](<https://devfeed.tech/topics/exception.md>), [Library](<https://devfeed.tech/topics/library.md>)

Tags: [coroutine](<https://devfeed.tech/tags/coroutine.md>), [deprecated](<https://devfeed.tech/tags/deprecated.md>), [library](<https://devfeed.tech/tags/library.md>), [tests](<https://devfeed.tech/tags/tests.md>), [unit-tests](<https://devfeed.tech/tags/unit-tests.md>)

### AI overview

A tutorial on testing Kotlin coroutines when code uses the Main dispatcher. It explains how to configure a TestCoroutineScheduler and TestDispatcher with kotlinx-coroutines-test, compares StandardTestDispatcher and UnconfinedTestDispatcher, and warns against the deprecated TestCoroutineDispatcher.

### Source excerpt

Using TestCoroutineScheduler, a scheduler for coroutines used in tests, that provides the delay-skipping behavior.

## 3.17.0 Release with Computed Columns, Audit Columns, Pattern Matching, Reactive Transactions and Kotlin Coroutine Support

DevFeed: [3.17.0 Release with Computed Columns, Audit Columns, Pattern Matching, Reactive Transactions and Kotlin Coroutine Support](<https://devfeed.tech/articles/3-17-0-release-with-computed-columns-audit-columns-pattern-matching-reactive-transactions-and-kotlin-coroutine-support-28926.md>)

Original publisher: [Read original article](<https://blog.jooq.org/3-17-0-release-with-computed-columns-audit-columns-pattern-matching-reactive-transactions-and-kotlin-coroutine-support/>)

Author: lukaseder

Published: 2022-06-22T15:15:05Z

Content type: release

Language: en

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

Topics: [releases](<https://devfeed.tech/topics/releases.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [reactive](<https://devfeed.tech/topics/reactive.md>), [Transactions](<https://devfeed.tech/topics/transactions.md>)

Tags: [audit-columns](<https://devfeed.tech/tags/audit-columns.md>), [client-side-computed-columns](<https://devfeed.tech/tags/client-side-computed-columns.md>), [computed-columns](<https://devfeed.tech/tags/computed-columns.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [implicit-join](<https://devfeed.tech/tags/implicit-join.md>), [java-17](<https://devfeed.tech/tags/java-17.md>), [jooq](<https://devfeed.tech/tags/jooq.md>), [jooq-3-17](<https://devfeed.tech/tags/jooq-3-17.md>), [jooq-development](<https://devfeed.tech/tags/jooq-development.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [pattern-matching](<https://devfeed.tech/tags/pattern-matching.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [r2dbc](<https://devfeed.tech/tags/r2dbc.md>), [reactive-programming](<https://devfeed.tech/tags/reactive-programming.md>), [reactive-transactions](<https://devfeed.tech/tags/reactive-transactions.md>), [release](<https://devfeed.tech/tags/release.md>), [release-notes](<https://devfeed.tech/tags/release-notes.md>), [sql](<https://devfeed.tech/tags/sql.md>), [stored](<https://devfeed.tech/tags/stored.md>), [stored-computed-column](<https://devfeed.tech/tags/stored-computed-column.md>), [udt](<https://devfeed.tech/tags/udt.md>), [virtual](<https://devfeed.tech/tags/virtual.md>), [virtual-computed-column](<https://devfeed.tech/tags/virtual-computed-column.md>)

### AI overview

The jOOQ 3.17.0 release adds client-side computed columns for read and write operations, audit columns, pattern-matching SQL transformations, and more implicit JOIN capabilities. It also sets Java 17 as the baseline for the Open Source Edition while commercial distributions continue supporting Java 8 and 11.

### Source excerpt

This release contiues the work from previous releases around more sophisticated SQL transformation capabilities, including: Client side computed columns for both read and write operations Audit columns Pattern matching SQL transformations More implicit JOIN capabilities Client side computed columns A ground breaking new core feature available in all commercial distributions isthe new client side computed ... Continue reading 3.17.0 Release with Computed Columns, Audit Columns, Pattern Matching, Reactive Transactions and Kotlin Coroutine Support ->

## Coroutines on Android

DevFeed: [Coroutines on Android](<https://devfeed.tech/articles/coroutines-on-android-23898.md>)

Original publisher: [Read original article](<https://medium.com/smg-real-estate/coroutines-on-android-d3e3413e6aa7?source=rss----2186e5b9bd8f---4>)

Author: Stevan Milovanovic

Published: 2022-05-20T12:36:23Z

Content type: tutorial

Language: en

Sources: [Homegate Engineering Blog - Medium](<https://devfeed.tech/sources/homegate-engineering-blog-medium.md>)

Topics: [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Android](<https://devfeed.tech/topics/android.md>), [async](<https://devfeed.tech/topics/async.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>), [context](<https://devfeed.tech/topics/context.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-apps](<https://devfeed.tech/tags/android-apps.md>), [article](<https://devfeed.tech/tags/article.md>), [async](<https://devfeed.tech/tags/async.md>), [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [cancellation](<https://devfeed.tech/tags/cancellation.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutine-testing](<https://devfeed.tech/tags/coroutine-testing.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [dispatcher](<https://devfeed.tech/tags/dispatcher.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [lifecycle](<https://devfeed.tech/tags/lifecycle.md>), [programming](<https://devfeed.tech/tags/programming.md>), [thread](<https://devfeed.tech/tags/thread.md>), [threads](<https://devfeed.tech/tags/threads.md>)

### AI overview

This tutorial explains why Kotlin coroutines can be preferable to threads for asynchronous and background processing on Android. It introduces coroutine scopes, contexts, suspending functions, jobs, and dispatchers, and describes using coroutines for networking and background processing.

### Source excerpt

Coroutines on Android In this article I'll try to explain why coroutines are useful and why would you want to use them in your project. After we go through the most important concepts of coroutines, I'll show you how I used coroutines to implement networking and background processing in the example project. First of all, you might ask yourself, why we want to use coroutines over threads? Main problem with threads is that they are resource intensive, meaning it takes a lot of resources to start a thread, stop a thread. Meanwhile, coroutines are lightweight threads, since they use thread pools. Another benefit of coroutines is that they greatly simplify asynchronous code. Callbacks and synchronisation are very easy to use. In fact, they make parallel programming look very much like sequential programming. Coroutines can be paused and resumed at any time, on a number of threads. And lastly, since coroutines are based on a few fairly easy to grasp concepts, their syntax is simple and easy to use. Here are the main concepts we need to explain about coroutines: Scope Coroutine scope, as its name says, defines a scope for new coroutines. Every coroutine builder (like launch and async) is an extension on CoroutineScope and inherits its coroutineContext to automatically propagate all its elements and cancellation. Context Coroutine context represents the context of its scope. Context is encapsulated by the scope and used for implementation of coroutine builders that are extensions on the scope. Scope provides a context in which the coroutine runs (state of the coroutine which provides variables, functionality of the coroutine etc.). Suspending functions Suspending functions are functions that can be run in a coroutine. They make callbacks seamless. They can be run in a coroutine (can be suspended) and that is why they can provide functionalities which have to be run in parallel. Job Job is a handle on that coroutine (on the piece of code which runs in the background). A laun

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

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

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

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

Content type: tutorial

Language: en

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

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

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

### AI overview

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

### Source excerpt

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

## Constructing a coroutine scope

DevFeed: [Constructing a coroutine scope](<https://devfeed.tech/articles/constructing-a-coroutine-scope-39234.md>)

Original publisher: [Read original article](<https://kt.academy/article/cc-constructing-scope>)

Published: 2021-10-13T00:00:00Z

Content type: tutorial

Language: en

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

Topics: [kotlin-coroutines](<https://devfeed.tech/topics/kotlin-coroutines.md>), [Structured concurrency](<https://devfeed.tech/topics/structured-concurrency.md>), [Back end](<https://devfeed.tech/topics/backend.md>)

Tags: [coroutine](<https://devfeed.tech/tags/coroutine.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [logging](<https://devfeed.tech/tags/logging.md>), [scope](<https://devfeed.tech/tags/scope.md>), [structured-concurrency](<https://devfeed.tech/tags/structured-concurrency.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

### AI overview

A tutorial on constructing Kotlin coroutine scopes for Android and backend code. It recommends holding a scope in a property, explains when a custom scope is needed, and discusses dispatchers, supervision, and exception handling.

### Source excerpt

How we generally define coroutine scope on Android and on the backend.

[Next page](<https://devfeed.tech/tags/coroutine.md?cursor=WyIyMDIxLTEwLTEzVDAwOjAwOjAwKzAwOjAwIiwgImU0ZTA0YTU5LTZhZDAtNDkwMC04Y2IyLWFkZjNiZjc3ZjkzNSJd>)