I use kotlin multiplatform which prohibits using runBlocking in common code since it is not supported by JS implementation.
My goal is to be able to call suspend functions from my non-suspend function like in the example below. Also I do not care about JS because I will use only JVM, Android, iOS targets
fun main() {
runBlocking {
doSomething()
}
}
suspend fun doSomething() {
}
One solution I can think about is to create expected and actual classes and make runBlocking call separately on each platform actual class, but I want to avoid this as it will cause some code duplication.
runBlocking {
doSomething()
}
Are there any better solution how to bridge blocking and non-blocking code together in common module?