DEV Community

Janak  bista
Janak bista

Posted on

Coroutines

A coroutine is a concurrency design pattern that we can use on Android to simplify code that executes asynchronously. Coroutines were added to Kotlin in version 1.3 and are based on established concepts from other languages.

On Android, coroutines help to manage long-running tasks that might otherwise block the main thread and cause your app to become unresponsive. Over 50% of professional developers who use coroutines have reported seeing increased productivity.

Features : Lightweight , fewer leakage ,jetpack Integration.

Based on the Guide to app architecture, the examples in this topic make a network request and return the result to the main thread, where the app can then display the result to the user.

Specifically, the ViewModel Architecture component calls the repository layer on the main thread to trigger the network request. This guide iterates through various solutions that use coroutines keep the main thread unblocked.

ViewModel includes a set of KTX extensions that work directly with coroutines.

Top comments (0)