Currently, I'm getting the instance of my logger with a custom tag by injecting with @InjectedParam
@Factory
fun getLoggerWithTag(
@InjectedParam tag: String?,
loggerConfig: LoggerConfig,
) = Logger(
config = loggerConfig,
tag = tag ?: "Shared",
)
@Single
internal class MySingleClass : KoinComponent {
// setting the tag of my logger with the parameter capabilities
val logger: Logger = get(parameters = { parameterSetOf("MySingleClass") })
}
As I can't use Koin API in the constructor, I need to declare an extra property to manage the logger parameters.
It is possible to avoid the first case? And doing something like the following example?
It will be easier to set default values or override them.
@Single
internal class MySingleClass(
@InjectingParam(parameters = { parameterSetOf("MySingleClass") })
val logger: Logger,
)
Hi,
Better explaining with an example
Currently, I'm getting the instance of my logger with a custom tag by injecting with
@InjectedParam
As I can't use Koin API in the constructor, I need to declare an extra property to manage the logger parameters.
It is possible to avoid the first case? And doing something like the following example? It will be easier to set default values or override them.
Thanks!