You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I have a FragmentAdapter with two constructor parameters: fragmentManager and a ViewModel.
I would like to inject it but I don't know what is the right way to put all the pieces together to declare the adapter in the koin module to be injected
val viewModel
by viewModel<AnnotationsViewModel>{
mapOf(
Properties.EXTRA_CONTENDER_ID to (getKey<AnnotationsKey>()?.id?:Utils.EmptyUUID),
Properties.EXTRA_ANNOTATION_ID to Utils.EmptyUUID
)
}
So I need to be able to define the bean to inject the keysadapter and I'm not sure how to define it on the koin module and how to inject it to be used in a fragment.
val pagerAdapter by inject<KeysPagerAdapter<AnnotationDetailKey>>{ mapOf(Properties.FRAGMENT_MANAGER to childFragmentManager)}
But this fails at it complains about missing parameters EXTRA_CONTENDER_ID and EXTRA_ANNOTATION_ID.
It makes sense as it doesn't know how to resolve, but I don't know how to define the bean or how to pass the paramenters the inject to obtain it...
The text was updated successfully, but these errors were encountered:
If you want to use function parameters in your definition,
you just have to use the params arguments as you do. To inject parameters values, open a lambda behind by inject or by viewModel and fill a map of values.
But this is what you already done. I don't understand well where is the problem :/
Can you provide a small project to be able to better understand your case?
Hello,
I have a FragmentAdapter with two constructor parameters: fragmentManager and a ViewModel.
I would like to inject it but I don't know what is the right way to put all the pieces together to declare the adapter in the koin module to be injected
The element that I need to inject:
where FocusableViewModel is an interface:
I want to create a keysPagerAdapter with the following viewModel injected:
This viewModel is being created without problems to feed a fragment. It is defined in the koin module
and it is being used in a fragment:
So I need to be able to define the bean to inject the keysadapter and I'm not sure how to define it on the koin module and how to inject it to be used in a fragment.
I've tried with this:
And injecting it through:
But this fails at it complains about missing parameters EXTRA_CONTENDER_ID and EXTRA_ANNOTATION_ID.
It makes sense as it doesn't know how to resolve, but I don't know how to define the bean or how to pass the paramenters the inject to obtain it...
The text was updated successfully, but these errors were encountered: