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

Alexjok

11/01/2019, 9:07 AM
Hello, how i can do something like that
Copy code
suspend fun test() {
async {  someWork()  }
}
How call async inside suspend fun?
g

gildor

11/01/2019, 9:09 AM
use coroutineScope function
Copy code
suspend fun test() {
 coroutineScope {
    async {  someWork()  }
  }
}
But your and my sample actually incorrect, you should do something with result of this async, otherwise it useless
a

Alexjok

11/01/2019, 9:12 AM
That example for simplicity. In my code i processed result) Thanks!
g

gildor

11/01/2019, 9:22 AM
Do you run multiple async in parallel?
a

Alexjok

11/01/2019, 9:29 AM
yes, i start multiple async from list, something like
Copy code
list.map { async {  convert()  }  }.awaitAll()
and after work with that in usual way
g

gildor

11/01/2019, 9:29 AM
Right