From the course: Kotlin Essential Training: Object-Oriented and Async Code
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Working with coroutines - Kotlin Tutorial
From the course: Kotlin Essential Training: Object-Oriented and Async Code
Working with coroutines
- [Instructor] By leveraging the co-routine APIs from Kotlin X co-routines, we can start building multithreaded code using a few basic APIs. Let's jump in and learn how to start leveraging co-routines for asynchronous programming in Kotlin. To start leveraging the co-routine APIs, we need to add the co-routine's dependency to our project. So if we go to our project window on the left side of the screen here and open our build.gradle.kts file, we should see that the coroutines dependency has already been added. If it hasn't, you're looking for KotlinX-coroutines- core version 1.6.0. Now, once this dependency has been added and the Gradle old project has been synced, we should be ready to use the coroutine APIs. So we'll come back over to our main.kt file here and we should now be ready to launch our very first coroutine. To launch a coroutine, we need access to a coroutine scope. The easiest way to access a scope is…