Replies: 2 comments
-
|
for now 3.5/4.0 you can't do such definition. Things need to challenged in 4.x |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I've come across this type of problem when I want to load secrets from aws secrets manager client and have the loaded secrets be registered as an instance in koin. I basically just solve this with mutable variables and doing the suspending / loading outside of koin. a trivial example looks like: class SecretsStore {
var secrets: Secrets? = null
suspend fun load() {
// do the work
// set secrets
}
}
data class Secrets(val password: String)
val koinApp = koinApplication {
modules(module {
single<SecretsStore> { SecretsStore() }
single<Secrets> {
checkNotNull(get<SecretsStore>().secrets)
}
})
}
// do this early on in the app lifecycle before resolving objects that depend on Secrets
koinApp.get<SecretsStore>().load() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
have object which created by suspend function like:
suspend fun someSuspendFunction(): MyPreciousObjectAnd I need to provide it for later injection using koin, like:
Any ideas how to resolve this kind of situation? And please bear in mind that I can't change
someSuspendFunction()P.S. I'm using Kotlin JS/WASM environment, so
runBlockingdoesn't existP.P.S. Original question - in StackOverflow
Beta Was this translation helpful? Give feedback.
All reactions