Hi all. Is there a way for me to pass a variable to a module when initializing it in startKoin? Use case -> I have a library that provides login screen for multiple applications. It needs a different API url for each application, which is used in providing the Retrofit service singleton by Koin. Is there a way for me to achieve this?
Alternatively, you could create your submodules as functions with parameters instead of properties. instead of
Copy code
val myModule = module {
...
}
do
Copy code
fun myModule(baseUrl: String) = module {
...
}
m
maddy
08/31/2019, 2:53 AM
Thanks Casey. I did not know that you could define the module as a function! 😍
Properties will work for the server url. I also wanted to pass an activity class as a parameter (basically the next activity to open once login succeeds). Function definition should work for that.
Thanks again 🙂