RJ Garcia
09/20/2024, 4:15 PMenvironment.monitor.subscribe(ApplicationStarted) { app ->
val secrets = app.getKoin().get<SecretsService>()
// option 1
runBlocking() {
secrets.load() // this is a suspendable function
}
// option 2
runBlocking(app.coroutineContext) { secrets.load() }
// option 3
val job = app.launch { secrets.load() }
runBlocking { job.join() }
}
But i've read a lot of articles about how dangerous runBlocking can be, and honestly, i don't quite have a good enough mental model of how it works to really understand the implications / trade offs of different approaches.
Would love any guidance on the specific problem but also general pointers on how to think about using runBlocking and coroutine contexts and such.RJ Garcia
09/20/2024, 4:16 PMLeo N
09/22/2024, 9:17 AMAleksei Tirman [JB]
09/23/2024, 7:29 AMRJ Garcia
09/23/2024, 5:06 PMRJ Garcia
09/23/2024, 5:08 PM