I checked how to injection parameter API.
val myModule = module {
single { (view : View) -> Presenter(view)) }
}
class View {
val presenter : Presenter by inject{ parametersOf(this) }
}
But it's difficult to how to inject it in java code.
Would you show me how to inject in java code?
not possible in Java, have to check if we can provide something for java :/
In java, instead of by inject ( parametersOf(this)) you should write something like KoinJavaComponent.inject(YourClass.class, ... , () -> parametersOf(this));
Please provide code detail if can.
Please provide code detail if can.
KoinJavaComponent.inject(
YourClass.class,
null,
() -> DefinitionParametersKt.parametersOf(instanceOfParameter1, instanceOfParameter2..)
);
@leimenghao1991 thank you for this sample code. This should have been included in the official Koin doc!
Most helpful comment
KoinJavaComponent.inject(
YourClass.class,
null,
() -> DefinitionParametersKt.parametersOf(instanceOfParameter1, instanceOfParameter2..)
);