Book doesn't explain pattern to register env key from library
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 9.7k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
The force in my opinion of Druid is the simplicity of getting started to build new customized widgets. This is also (for now) a weakness as the list of available built-in widgets is thin.
Assuming a scenario where a user builds a library of widgets for use in third-party apps. The Env section of the Druid book explains about theming and how to declare keys. It then proceed to explain keys must be registered by the app. Unfortunately in this scenario the library author is not the one who launches the app, so has no access to registration. There doesn't seem to be any alternative to register the keys automatically.
The pattern I see to work around this is, instead of assuming keys are set like built-in Druid widget do (calling Env::get()), the library author should probably use Env::try_get() and provide the same default as the key if it is not set. I think this workaround should at least be documented, or better a solution provided for this use case, possibly by adding a default value to the key itself.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Env section of the Druid book and review the mentioned Env::get(), Env::try_get(), key declaration, and application registration behavior. Document the supported pattern for library-defined keys, or clarify what solution is intended for libraries whose applications cannot register them; done means the library use case and default-value behavior are explained.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100