Tóth István Zoltán
07/08/2023, 4:08 AMTóth István Zoltán
07/08/2023, 4:40 AMfun main() {
if(js("typeof self.importScripts === 'function'") as? Boolean == true) {
workerMain()
} else {
uiMain()
}
}
fun uiMain() {
println("UIMain")
CoroutineScope(Dispatchers.Default).launch {
Worker("/z2-rpc-test-multiplatform.js")
}
}
fun workerMain() {
println("WorkerMain")
}
Big Chungus
07/08/2023, 8:54 AMBig Chungus
07/08/2023, 8:55 AMturansky
07/08/2023, 2:47 PMWell, it seems to be working. Why is this discarded, is there something I don’t see/know?Also some static imports or extension calls can produce variable declaration at start of JS file. As result - worker will crash.
// static import for `ELEMENT_NODE`
var ELEMENT_NODE = Node.ELEMENT_NODE
Tóth István Zoltán
07/10/2023, 7:59 AMTóth István Zoltán
07/10/2023, 8:00 AMturansky
07/10/2023, 11:14 AMThe worker crashing is a problem. Does this happen when the worker tries to access something that is not available for workers?Yes
turansky
07/10/2023, 11:16 AMThis worker would perform a websocket communicationIf you will use Browser API only big chunk isn’t expected
turansky
07/10/2023, 11:27 AMoutput.granularity
- first step.
Otherwise app DCE will be applied workers.
• Second step - task dependencies.
To find workers in app dependencies I use separate Gradle configuration jsMainModule
.
runtimeOnly
couldn’t be used for this goal.