configField

inline fun <T : Any, V> configField(noinline selector: (T) -> V): ReadOnlyProperty<Any?, V>(source)

Property delegate that lazily extracts a field from a registered config.

val dbUrl: String by configField<AppConfig, String> { it.database.url }
val port: Int by configField<AppConfig, Int> { it.server.port }

class UserRepository {
private val dbUrl: String by configField<AppConfig, String> { it.database.url }
}

fun <T : Any, V> configField(type: KClass<T>, selector: (T) -> V): ReadOnlyProperty<Any?, V>(source)

configField for when the config type is only known as a KClass.