so i know i cannot block on javascript.. but does ...
# coroutines
n
so i know i cannot block on javascript.. but does anyone have a snippet for kotlin-js that does approximately the same thing as runBlocking and returning the result ? something like
Copy code
val derferred = async {  ... }
while(!deferred.isCompleted) {
   delay(10)
}
return deferred.getCompleted()
except since i am not in a coroutine i cannot use delay outside of it..
m
Well, you already know the answer 😉 Not possible.
n
how would one then implement things like initlaizing dependencies in eg. koin in a
() -> T
? if there was a callback or such i could do
.then
..
m
Dependencies are initialized synchronously. No coroutines, no async code.
b
My advice would be to have your entire app in suspend scope. Starting with "suspend fun main() {}"
If you really want to have something "blocking" you can implement it with while loop polling for completion