selecting

fun <R> selecting(selector: (T) -> R): ReadOnlyProperty<Any?, R>

Creates a Kotlin property delegate that extracts a sub-section or derived value from the config.

The selector is evaluated on every property access, so the returned value is always in sync with the latest config.

class StatsManager(config: ConfigRef<DuelsConfig>) {
private val db by config.selecting { it.database }
private val apiKey by config.selecting { it.statsApiKey }
private val dbUrl by config.selecting { "${it.database.host}:${it.database.port}" }

fun connect() {
// db, apiKey, dbUrl — always fresh after any reload
}
}

Return

A ReadOnlyProperty delegate.

Since

1.0

Parameters

R

The type of the selected value.

selector

Function that extracts a value from the config.