From the course: Intermediate Kotlin for Android Developers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Anko coroutines: Launch basics
From the course: Intermediate Kotlin for Android Developers
Anko coroutines: Launch basics
- (Instructor) Before we start working with coroutines in our code directly. Let's go over working with the launch function, by means of a few text examples. So we're here in the coroutines launch test class, and we're going to start by adding some code to the start with launch no sleep method. Now the most basic way to start a coroutine is with the launch function. So we're going to start here on line nine, and we're just going to add a few markers for ourselves, by means of print line statements. So we're going to do starting, duplicate this, and then we're going to put stopping. Okay, and in between is where we'll handle our coroutine information. So first with the call to launch, this is how we're going to initiate our coroutine. Now let's just take a quick peek at the definition of this particular function. You'll see that it takes in the coroutine context, which is related to the threads that you want your work to happen on. Next, the coroutine start enum, which gives you some…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.