-
-
Notifications
You must be signed in to change notification settings - Fork 719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add modules dynamically to the graph #419
Comments
Ok, I might have found the solution:
And then the activity within Feature module 1 just does:
|
Isn't the @luislukas @arnaudgiuliani If I have a dynamic feature module with only Fragments, no Activities, then where would I call the EDIT: Maybe this issue can help: #420 |
@haroldadmin Seems that
Feels cleaner loading extra modules on the fly with
Also, I've verified that the |
@luislukas The lazy loading part is not that important. What's important is that the lazy delegate executes the loadKoinModules function only once. The lazy loading part helps us hold off loading the modules until the fragment is actually created. |
@haroldadmin Looking at what
Root cause of this is this method in
Seems that a mechanism to keep track of what has been added is necessary in order to avoid the exception, or somehow, play with different gradle flavours and load all the definitions at the same time. cc: @arnaudgiuliani |
It would also be great if we could get official documentation on how to use Koin in dynamic feature modules with fragments/activities. |
yeah There can be a good article about dynamic modules architecture :) |
I'm running into the same issue. Would be great if we can either: @arnaudgiuliani The internal check to not override existing modules is perfect, though a boolean to be able to ignore the exception would be great. In a multi-module dynamic Android App, I could do this in my Activity: Right now, the problem is that a component outside Koin doesn't know if it's module definitions have been loaded into Koin, and no way to check if it fails other than wrapping in a try-catch. I'd love to pick this feature up if up for contribution! Doesn't seem like a major change. |
Choosing not to throw an exception would be really useful since I have the feeling that the trick of override modules will load again the dependencies so +1 to @calvinnor suggestion. |
an unloadKoinModules() function that would unload given definitions instances? |
here is the usecase for
|
added to Koin |
@arnaudgiuliani I am trying to using loadKoinModules() in a signed APK and it doesn't seem to be working. If i build a debug APK, i am able to override modules. Is there any specific setting which needs to be set to make it work with signed APKs?
|
I've used I'd like to load my mocked test modules instead of loading the whole feature's modules. |
Hi,
I haven't been able to find this information through the docs, although I believe could be related to Koin context isolation.
Issue #224 might have clues as well, but again, couldn't figure it out.
I'm trying to find out how once we define the main app module and invoke startKoin:
startKoin { modules(appModule) }
then another Feature module could add it's own dependencies to the graph (this module will require some instances from the main app module as well).
We have an app based on Dagger and we would like to migrate it to Koin. In dagger, we basically declare the common components within a
base
module and the feature components, in different module, have adepends
relationship with thebase
. The idea it's that the main app/base module won't have to import the differentmodule
from the features.I've tried to do the following within the custom Application:
then each feature module would get an instance of
MyKoinContext.koinApp
and add its particular module, but I've had no luck.I could see this working, maybe with different gradle flavours but I'm trying to avoid that option
since won't scale properly.
Any guide will be appreciated!
The text was updated successfully, but these errors were encountered: