Vampire
08/12/2020, 6:28 PMrunBlocking
as it does not exist for Kotlin/JS intentionally.
Actually right now I just declared the fun main()
as suspend fun main()
and it seems to work properly.
Just want to double-check whether this is the correct way. 🙂turansky
08/12/2020, 6:38 PMGlobalScope.launch
can be more usefulVampire
08/12/2020, 6:38 PMturansky
08/12/2020, 6:41 PMturansky
08/12/2020, 6:43 PMgradle-cache-...
:)Vampire
08/12/2020, 6:47 PMI can be called in any placeYou mean the
GlobalScope.launch
?
I fear I still don't understand.
I'm calling a suspending function in main
anyway if what you meant was, that it does not have to be in the entrypoint method but can be called deeper in the context
Also, didn't I read that GlobalScope.launch
will be like daemon threads and thus not hinder the process to quit in the coroutines docs?
Or is this not relevant for JavaScript as it is a single-threaded language anyway?
1. AFAIK You will have possibility to use custom context to sync coroutinesI will probably not have multiple coroutines anyway, just some sequential code, but calling methods returning promises, so I use
.await()
on themturansky
08/12/2020, 7:02 PMsuspend main
enough - good
If you need sync group of promises - you can use launch
turansky
08/12/2020, 7:05 PMlauch
- more 'clear' solution as for me, which can be simply copied in another functionVampire
08/12/2020, 7:09 PMsuspend
for now until I need more or change my mind. :-Daraqnid
08/12/2020, 8:07 PMmain()
— it gets run even when you’re running the tests. I have some extra Gradle taskage to produce script stubs to call top-level entry pointsturansky
08/12/2020, 8:35 PM