Hi, My MPP is a lib that has JVM and JS targets. ...
# multiplatform
a
Hi, My MPP is a lib that has JVM and JS targets. The library contains an object that launches a coroutine that polls a server on an interval while (isActive). This starts up first, but, in a JS app, it seems that it blocks the application from processing anything else in the library (or the application, for that matter). I'm assuming (and I'm not a JavaScript expert, nor do I intend to be) that the polling is blocking the main thread in Node, since when I disable that object, things seem to flow fine. Is my assessment correct? If so, what patterns/best practices can I use to solve for this? Thanks! Slack Conversation
a
@strooooke Many thanks!
s
JavaScript is single threaded. If you're running something in a tight loop and the loop never exits, your app will never execute any other code. Coroutines will execute on your main thread in JS.
a
it seems that the await() point of an async call hangs the thread. I'm using the native-mt coroutines, but that doesn't seem to help. Removing the async/await does, however. These async calls are to ktor HttpClient.get/put, which I'd like to execute simultaneously.