zalewski.se
06/07/2020, 12:51 PMnetwork <--\ / <-- home <--\
| repository | | app
database <--/ \ <-- login <--/
In such scenario (app depends on home&login where home&login depends on repository where repository depends on network… etc, depends on mean using implementation
, not api
), how to manage Koin modules? I was thinking of having network provide it’s own modules and passing it up to repository, repository would consume it, add it’s own and pass it up further.. This will cause the problem where many network and repository koin modules would be provided to the app module (I know I can fix it by allowing overriding the modules) . It’s also not so flexible for testing, I can’t provide testNetwork module in home or login feature as these modules are unaware of the network. Another thing is that I can’t really test database as it’s needs to be aware of Android context (sqldelight..) so to test checkModules configuartion I would need to mock it there.
Different idea I had was to create another module like di
that would be aware of all the modules that expose some Koin modules. In di
I would connect everything together and expose it for the app module (which would depend on di
). But this doesn’t really solves the problem with testing 🤔voben
06/08/2020, 11:54 PMEgor Babarykin
06/11/2020, 12:32 PMAllan Wang
06/17/2020, 9:29 AMjava.lang.IllegalStateException at KoinContextHandler.kt
From ./gradlew testDebug
? I’ve used koin before in a few projects and this one is internal. It extends AutoCloseKoinTest
and fails for certain files exactly every other time. Using ./gradlew clean testDebug
fixes it, but I’m not sure what the issue is. Curious if anyone has experienced the same thingSantosh Astagi
06/19/2020, 1:43 PMstreetsofboston
06/19/2020, 7:04 PMsingle { SomeClass.Factory(...) }
single { SomeOtherClass.Factory(...) }
(on Kotlin Multi Platform), I get this error:
java.lang.IllegalStateException: InstanceRegistry already contains index 'Factory'
How can I make Koin use the qualified class name instead of just the inner class’ name?
It is probably of this code in the jvm target of Koin:
actual fun className(kClass: KClass<*>): String = kClass.java.simpleName
Why is simpleName
used and not the full-name?ParkWoocheol
06/22/2020, 6:49 AMDeepti M
06/24/2020, 9:16 PMFatal Exception: java.lang.RuntimeException
Unable to start activity ComponentInfo{MainActivity}: org.koin.core.error.InstanceCreationException: Could not create instance for [Single:'com.google.firebase.database.FirebaseDatabase']
android.app.ActivityThread.performLaunchActivity
keyboard_arrow_down
Caused by org.koin.core.error.InstanceCreationException
Could not create instance for [Single:'com.google.firebase.database.FirebaseDatabase']
org.koin.core.instance.InstanceFactory.a
keyboard_arrow_down
Caused by com.google.firebase.database.DatabaseException
Calls to setPersistenceEnabled() must be made before any other usage of FirebaseDatabase instance
Sean McQuillan [G]
06/29/2020, 6:40 PM@Composable
fun <T> koinInject(): T {
val context = KoinContext.get() // this won't recompose if KoinContext is changable, if that is so this should become an Ambient
return remember(context) { context.inject() } // inject only called once per component per context (but doesn't trigger recomposition when context changes)
}
Wanted to post it here to see what the requirements are. Code like this would make it behave similarly to a member variable.Abhishek Bansal
07/06/2020, 10:27 AMCaused by k.a.c.f.e: No definition found for '<package>.h' has been found. Check your module definitions.
at org.koin.core.scope.Scope.findDefinition(Scope.java:52)
at org.koin.core.scope.Scope.resolveInstance(Scope.java)
at org.koin.core.scope.Scope.get(Scope.java:123)
at org.koin.androidx.viewmodel.ViewModelResolutionKt$createViewModelProvider$1.create(ViewModelResolutionKt.java:25)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:37)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:23)
at org.koin.androidx.viewmodel.ViewModelResolutionKt.getInstance(ViewModelResolutionKt.java:119)
at org.koin.androidx.viewmodel.ViewModelResolutionKt.getViewModel(ViewModelResolutionKt.java:26)
This even happens in local testingNikola Milovic
07/07/2020, 4:15 PMHakob Astvacatryan
07/07/2020, 8:13 PMNikola Milovic
07/13/2020, 4:57 PMopen class App : Application() {
override fun onCreate() {
super.onCreate()
startKoin {
// Android context
androidContext(this@App)
// modules
modules(com.example.core.di.networkModule, (com.example.homeFeed.di.)viewModelModule, (com.example.homeFeed.di.)repositoryModule, com.example.homeFeed.di.networkModule)
}
}
}
But I crash with this as the output https://hastebin.com/qizixidumu.sql
Also is there a better way to handle koin modules in a multimodule app? Like having an array of modules and then just loading them when needed as the fragments change? Thank you!Allan Wang
07/13/2020, 7:11 PMcheckModules
test viewModel modules? I’m having an issue with resolving a class that has a provider, and after commenting things out I realize none of the viewModel providers seem to be testedzsperske
07/15/2020, 5:40 PMArpan Sarkar
07/28/2020, 7:30 PMreevn
07/29/2020, 3:16 PMclass A : Disposable
). Disposable
offers a dispose
function that every such component needs to implement.
Is there a way to let Koin trigger dispose
of all loaded dependencies once unloadModule(...)
is called?Alex
07/30/2020, 4:06 PMkzotin
08/03/2020, 9:03 AM@WorkerThread
thread? (e.g. in FirebaseMessagingService
)
Is it considered OK or discouraged?Fabio
08/07/2020, 6:24 AMcheckModules
. As I understand it only checks if there are gaps inside the module graph. But if I try to check for a leaf of the graph it won't fail, such as forgetting to add a factory { B() }
in the following case.
class A : KoinComponent {
val b : B by inject()
}
class B {
}
Is there any way to check for that too without having to write specific tests for specific classes? (which I may forget)gps
08/10/2020, 11:14 AMarnaud.giuliani
08/11/2020, 7:40 AMarnaud.giuliani
08/19/2020, 8:00 AMarnaud.giuliani
08/19/2020, 8:18 AMJavier
08/19/2020, 8:59 AMget()
? it is recommended to not use in Android, maybe moving from reflection to some another alternative (arrow meta maybe?)Javier
08/20/2020, 1:59 PMarnaud.giuliani
08/21/2020, 1:31 PMzsperske
08/27/2020, 2:18 PMAbhishek Bansal
08/29/2020, 6:50 AMunloadKoinModules
actually do? What is meant by
unload Koin modules from global Koin context
Does it not destroy the instances module contain?Davide Giuseppe Farella
08/29/2020, 1:58 PMfactory { MyParams(...) }
factory { (p: MyParams) -> MyClass(param = p) }
factory { MyClass(param = get() }
Davide Giuseppe Farella
08/29/2020, 1:58 PMfactory { MyParams(...) }
factory { (p: MyParams) -> MyClass(param = p) }
factory { MyClass(param = get() }
tynn
08/29/2020, 5:54 PMDefinitionParameters
directly.