Coroutines is not launched in Intellij Idea plugin

Answered

I tried to use coroutines in my plugin, but I can not launch it by:

GlobalScope.launch
CoroutineScope(Job() + Dispatchers.IO)

Is it possible to use coroutines in plugin development?

0
5 comments

It is possible to work with coroutines. The following snippet should work:

launch(CoroutineScope(Job() + Dispatchers.IO)) {
// ...
}
0

Do I have to add coroutine dependency? I can not find the `launch` method you mentioned.

0

Definitely:

compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesVersion"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-swing:$kotlinCoroutinesVersion"
0

I tried, but still couldn't find the method you mentioned. The version I used is `1.3.7`.

0

Such methods are available in 1.3.7:

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
0

Please sign in to leave a comment.