Jakub Gwóźdź
07/13/2023, 8:53 AMdata class Config(val fooConfig: String, val barConfig:String)
fun appModule() = module {
single { ConfigProvider().load() }.bind(Config::class)
single { Foo(get<Config>().fooConfig) }
single { Bar(get<Config>().barConfig) }
}
and now I’d like to make fooConfig
and barConfig
nullable and create Foo(…)
and Bar(…)
only when their configs are not-null.
Is there a way to do it?s3rius
07/13/2023, 6:08 PMsingle { get<Config>().barConfig?.let { Bar(it) } }
s3rius
07/13/2023, 6:08 PMJakub Gwóźdź
07/13/2023, 6:09 PMs3rius
07/13/2023, 7:04 PMnull
for a valid value, even if the type is nullable. Even just single<String?> { null }
fails the check.
I guess you can get around it by using Option<Bar>
.Jakub Gwóźdź
07/14/2023, 4:52 AM