Kotlin Coroutine Context & Scope — A Practical Guide | by Omar | Apr, 2025

Kotlin Coroutine Context & Scope — A Practical Guide | by Omar | Apr, 2025

Coroutines are now essential for writing clean, responsive, and modern Android apps. This guide breaks down coroutine context and scope — what they are, how they work, and how to use them effectively. Whether you’re a beginner or an experienced developer, this article can serve as a powerful reference. A CoroutineContext holds metadata for how … Read more

Jetpack Compose Coroutine: Call a suspend function – ivanlocode

Jetpack Compose Coroutine: Call a suspend function – ivanlocode

LaunchedEffect: Auto trigger when the composable enters the composition. Auto cancel the coroutine when the composable exit the composition. No need to worry about the coroutine’s lifecycle. @Composablefun myUI(){LaunchedEffect(Unit){loadDataFromInternet()}}suspend fun loadDataFromInternet(){delay(3000)Log.d(“MyDebug”,”Done”)} rememberCoroutineScope: Run it when response to user input (e.g. click a button) It will not call when the composable enters composition @Composablefun MyUI() {val … Read more

Kotlin Coroutine Cancellation, Explained | by Sam Cooper | Apr, 2025

Kotlin Coroutine Cancellation, Explained | by Sam Cooper | Apr, 2025

Safely stop suspending tasks for faster apps and fewer bugs Photo by Jad Limcaco on Unsplash Don’t let abandoned coroutines waste resources and tank your app’s performance. Keep things snappy by cancelling unneeded tasks as soon as you’re done with them. Let’s break down the how, why, and what of coroutine cancellation, so you can … Read more

Kotlin Coroutine Dispatchers: The Guide to Thread Management | by Ninad Bhase | Apr, 2025

Kotlin Coroutine Dispatchers: The Guide to Thread Management | by Ninad Bhase | Apr, 2025

Kotlin Coroutines revolutionized asynchronous programming by making concurrency simpler and more efficient. But how do they actually work under the hood? The secret lies in dispatchers — the component that decides where and when coroutines execute. While most articles explain the basics of Dispatchers.Default, IO, and Main, few dive into their internal mechanics. In this … Read more

Kotlin Coroutine Scopes: CoroutineScope vs SupervisorScope | by Ninad Bhase | Apr, 2025

Kotlin Coroutine Scopes: CoroutineScope vs SupervisorScope | by Ninad Bhase | Apr, 2025

Structured concurrency in Kotlin relies heavily on CoroutineScope and SupervisorScope to manage coroutine lifecycles. Let’s break down how they work internally and when to use each. Creates a scope where child coroutines are bound to the parent If any child coroutine fails, it cancels the parent and all siblings Uses a regular Job() internally fun … Read more

Kotlin Coroutine Scopes: CoroutineScope vs SupervisorScope | by Ninad Bhase | Apr, 2025

Kotlin Coroutine Scopes: CoroutineScope vs SupervisorScope | by Ninad Bhase | Apr, 2025

Structured concurrency in Kotlin relies heavily on CoroutineScope and SupervisorScope to manage coroutine lifecycles. Let’s break down how they work internally and when to use each. Creates a scope where child coroutines are bound to the parent If any child coroutine fails, it cancels the parent and all siblings Uses a regular Job() internally fun … Read more

Write Testable Time-Dependent Coroutine Code in Kotlin: Avoid System.currentTimeMillis | by Omar Sahl | Mar, 2025

Write Testable Time-Dependent Coroutine Code in Kotlin: Avoid System.currentTimeMillis | by Omar Sahl | Mar, 2025

Photo by János Venczák on Unsplash Whenever we need to access the current time in Kotlin, one of the simplest approaches that comes to mind is using the System.currentTimeMillis() function. It’s straightforward, it returns the number of milliseconds since the Unix epoch (1970–01–01T00:00:00Z). However, when it comes to writing testable code, relying on this function … Read more

🧵 How to Answer Like a Kotlin Coroutine Expert: Kotlin Coroutine Suspension Under the Hood | by Shbazhenov | Mar, 2025

🧵 How to Answer Like a Kotlin Coroutine Expert: Kotlin Coroutine Suspension Under the Hood | by Shbazhenov | Mar, 2025

Take this simple example: suspend fun functionA(param: Int): String {return “hello $param”} When compiled, the Kotlin compiler transforms it to something like: public static final Object functionA(int param, Continuation super String> $completion) {return “hello ” + param;} An extra parameter of type Continuation was added. The return type changed from String to Object (or Any? … Read more

5 Fatal Coroutine Mistakes Nobody Talks About in Android | by Emmanuel Iyke | Feb, 2025

5 Fatal Coroutine Mistakes Nobody Talks About in Android | by Emmanuel Iyke | Feb, 2025

As Android developers, Kotlin Coroutines have become an essential part of our daily workflow. They make asynchronous programming and concurrency handling feel effortless — almost too effortless. But that simplicity can be deceptive. Many developers unknowingly fall into subtle yet dangerous pitfalls that, at first glance, seem like best practices. Today, we’re pulling back the … Read more