In any definition, you can use injection parameters: parameters that will be injected and used by your definition.
Passing values to inject
Given a definition, you can pass parameters to that definition:
Parameters are sent to your definition with the
parametersOf() function (each value separated by comma):
Defining an "injected parameter"
Below is an example of injection parameters. We established that we need a
view parameter to build of
Presenter class. We use the
params function argument to help retrieve our injected parameters:
You can also write your injected parameters directly with the parameters object, as destructured declaration:
Even if the "destructured" declaration is more convenient and readable, it's not type safe. Kotlin won't detect that passed type are in good orders if you have several values
Resolving injected parameters
Koin graph resolution (main tree of resolution of all definitions) also let you find your injected parameter. Just use the usual