-
-
Notifications
You must be signed in to change notification settings - Fork 718
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
Forwarding parameters #66
Comments
Hello, I will allow propagating parameters in next patch. You will be able to use like: //with classes
class ComponentA(val componentC: ComponentC)
class ComponentB(val componentA: ComponentA) val simpleModule1 = applicationContext {
bean { params -> ComponentA(params["this"]) }
bean { params -> ComponentB(get(parameters = params.values)) }
}
// injecting ...
val componentB: ComponentB by inject(parameters = mapOf("this" to this)) |
@arnaudgiuliani How does this solves the OP's issue? I mean, in your example: But in the |
means that you will store if your definition is using a compatible type of the forwarded parameter, it will be ok. Did I respond to your question? |
Hey @arnaudgiuliani! |
Got it! |
yeah, it's a lambda. This can be a bit tricky. |
Hello. (while waiting for my kotlin slack invitation I'm writing here) I have the following module defined: val nextNewsModule = module {
single { (acc: SingleSignOnAccount) -> provideAuthenticationInterceptor(acc) }
single { params -> provideHttpClient(get { params }) }
single { (acc: SingleSignOnAccount) -> provideRetrofit(get { params }, acc) }
single { params -> provideNewsService(get { params }) }
single<NewsRepository> { params -> NewsRepositoryImpl(get { params }) }
viewModel { params -> NewsViewModel(get { params }) }
} and getting called by private val vm: NewsViewModel by viewModel { parametersOf(SingleSignOnAccount("a", "b", "c", "d")) } The problem before adding all the I got the |
I've got it working now by using single { params -> provideRetrofit(get { params }, params.component1()) } Such an example should still be put on the website though. Thanks for creating Koin! |
Koin 0.9.0 is really great
Thanks for the parameter support when injecting dependencies. It is working great.
I have a small optimization for injecting with parameters.
It would be fantastic if we can forward this parameter map.
e.g.
and the module looks like this
can you provide us with the possibillty to forward these params in the get() method, e.g
looking at the get() functions it should be possible
in the current version 0.9.0 you pass an emptyMap to the resolve functions.
maybe we can do something like this:
What do you think about this?
The text was updated successfully, but these errors were encountered: