Jonathan
09/07/2025, 2:19 AMlateinit and enforce calling an "init" function at startup but that seems messy. Is there an obvious solution that I'm missing?arnaud.giuliani
09/10/2025, 3:11 PMkoinApplication function. From this you have an isolated context, in the sense where it's not loaded in the main/static context.arnaud.giuliani
09/10/2025, 3:12 PMarnaud.giuliani
09/10/2025, 3:12 PMJonathan
09/10/2025, 3:30 PMkoinApp is a property I couldn’t provide arguments to its initialization block.
My workaround was to define an init(ContextWrapper) function MyIsolatedKoinContext object declaration and have it call an expect/actual function that in androidMain/ will explicitly add a new module that holds the Android Context.
Here is the function:
actual fun KoinApplication.platformInitialize(espContext: ESPContext) {
modules(
module {
espContext.appContext.also { appContext ->
if (appContext is Application) {
single { appContext } bind (Context::class)
} else {
single { appContext }
}
}
}
)
}