Koin: how to use parametersOf in java code

Created on 16 Jul 2019  路  5Comments  路  Source: InsertKoinIO/koin

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?

question

Most helpful comment

Please provide code detail if can.

KoinJavaComponent.inject(
YourClass.class,
null,
() -> DefinitionParametersKt.parametersOf(instanceOfParameter1, instanceOfParameter2..)
);

All 5 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iRYO400 picture iRYO400  路  3Comments

ILAgent picture ILAgent  路  3Comments

dakuenjery picture dakuenjery  路  4Comments

guymclean picture guymclean  路  3Comments

fmobus picture fmobus  路  4Comments