Coroutines 1.3.5

Coroutines are no longer experimental, but appear to be implemented a bit differently…

Listing 22.6 - Skip the kotlin block on top & replace the dependencies line as follows:
implementation ‘org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5’

Listing 22.7 - Replace async{…} with GlobalScope.async{…}

Listing 22.8 - Replace launch(UI){…} with runBlocking{…}

Add the following to NewCharacterActivity.kt:
import kotlinx.coroutines.runBlocking

Add the following to CharacterGenerator.kt:
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.Deferred

2 Likes