0Pricing
Android Academy · Lesson

Coroutine Basics and Scopes

Launch coroutines in the right scope.

What Are Coroutines?

Coroutines let you write asynchronous, non-blocking code in a sequential style. They are Kotlin’s answer to callbacks and threads for tasks like network and database I/O.

suspend Functions

A function marked suspend can pause without blocking the thread and resume later. It can only be called from a coroutine or another suspend function.

suspend fun fetchUser(): User {
    delay(1000) // non-blocking pause
    return User(1, "Ada", "ada@x.com")
}

All lessons in this course

  1. Coroutine Basics and Scopes
  2. viewModelScope and Dispatchers
  3. Kotlin Flow Basics
  4. StateFlow and SharedFlow
← Back to Android Academy