Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Enums as config items #15

Open
jamiesanson opened this issue Oct 6, 2020 · 0 comments
Open

Support Enums as config items #15

jamiesanson opened this issue Oct 6, 2020 · 0 comments

Comments

@jamiesanson
Copy link
Contributor

We're not able to enforce type constraints on config providers themselves, but from an end-user perspective it'd be useful to be able to model config items as enums straight out of the box. By default the mapping would be to and from the enum "value", making use of Enum Generics.

An example of how this might look:

enum class ThemeAccent {
    LightBlue,
    BrightGreen
}

// in SubConfig implementation
val themeAccent by config<ThemeAccent>()

Implementation-wise, the delegate function can be selected via overload resolution. An implementation such as this should suffice:

inline fun <reified T: Enum<T>> ConfigRegistry.config(/*...*/): ConfigRegistrar<T> = ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant