https://kotlinlang.org logo
#coroutines
Title
# coroutines
c

CLOVIS

07/27/2019, 9:38 AM
I watched the amazing talk from KotlinConf 2018 and I'm trying to use the same example with an extension function on CoroutineScope, however I can't seem to be able to import it in Kotlin/Multiplatform, is it not implemented? IntelliJ suggests CoroutineContext, but I don't know if those are equivalent or not
g

gildor

07/27/2019, 9:43 AM
Have you add kotlinx.coroutines to your MPP project?
CoroutineScope is part of kotlinx.coroutines library, not a part of Kotlin stdlib
c

CLOVIS

07/27/2019, 10:01 AM
Looks like that was the problem. The official readme only gives artifacts for native, JS, and Android. Is there one for regular JVM? From the text it seems to me that the Android is specific and cannot be used for standard JVM
g

gildor

07/27/2019, 10:19 AM
You just need core artifict (available for all platforms) https://github.com/Kotlin/kotlinx.coroutines/blob/master/README.md#gradle
Android, is just Android specific artifact that provides integration with Android Main thread
See the description of all kotlinx.coroutines libraries: https://github.com/Kotlin/kotlinx.coroutines/blob/master/README.md#modules
c

CLOVIS

07/27/2019, 1:16 PM
Oh, I thought Multiplatform needed the core + implementation in each platform
g

gildor

07/27/2019, 1:28 PM
Yeah, jvm version is called just kotlinx-coroutines-core 🤷‍♂️ Also it's possible now with Gradle metadata publish library that has info about artifacts for different platforms, this is what Kotlin MPP does
c

CLOVIS

07/27/2019, 6:50 PM
Oooh so this is what metadata does!
Also, thanks you were right it fixed my problems
3 Views