Mobile development

Stage 1 · Lesson 8 of 9

Coroutine basics

Kotlin fundamentals

let you write async code that reads top to bottom, like normal code. A suspend function can pause without blocking its thread, for example while it waits for the network. You start coroutines from a scope.

Use launch for work with no result, or async when you need a result later with await. Structured concurrency means every coroutine belongs to a scope. When the scope is cancelled, its children are cancelled too.

For example, viewModelScope is cancelled when the screen goes away. decide which threads run the work: withContext(Dispatchers.IO) moves blocking work, such as reading a file, off the .

Common trapGlobalScope or runBlocking in app code: the first leaks work, the second freezes the .

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

  • GuideFree
    Kotlin Documentation

    JetBrains

    Start with the Kotlin tour, then the null safety and coroutines basics pages

  • CourseFree
    Android Basics with Compose

    Google · Beginner

    The Kotlin pathways in Units 1 to 3 teach the language with practice sets

Practise

  • Dart, TypeScript, Kotlin and Swift tracks with small exercises and free mentor feedback

Keep handy

  • Short Kotlin pages with a try-it editor for checking syntax quickly

Also worth your time

Mark this stage as not done?